The question is answered, right answer was accepted
How to Make Object Spin While Moving?
I have the simplest script ever that moves the hammer and makes it rotate. This is it:
using UnityEngine;
using System.Collections;
public class HammerMover : MonoBehaviour {
void Update () {
transform.Rotate (0f, 360f, 0f);
transform.Translate (0.1f, 0f, 0f);
}
}
My question is this: How do I make the hammer rotate along the Y axis while it is moving down the X axis? Think like someone is throwing it at you. Right now, the hammer just moves in circles and I cannot figure out how to alter it. Thanks all :)
Answer by Ali-hatem · May 01, 2016 at 11:46 AM
public float speed,rotSpeed;
void Update(){
transform.position += Vector3.up * speed;
transform.Rotate (rotSpeed,0,0);
}
you welcome & you will love your previous problem as i did once because i found a beautiful way to rotate object around something .
public float diameter;
public float RotateSpeed;
public Transform target;
void Update(){
transform.position = target.position;
transform.Translate(diameter,0,0);
transform.Rotate(0,0,RotateSpeed);
}
Follow this Question
Related Questions
Why doesn't transformation Position & rotation work? 0 Answers
how do I rotate an object without affecting later rotation? 0 Answers
when trying to rotate, the object transforming itself 0 Answers
How to translate an object in an unknown angle ? 1 Answer
My rotation is not the same in inspector as it is in the scirpt 0 Answers