- Home /
Question by
Abdou23 · Dec 13, 2015 at 02:45 PM ·
rotationquaternionvelocity
Move object in rotating direction.
I have an object that is being rotated constantly, I want to move that object towards that moving direction on a mouse click.
void Update ()
{
if (stationary)
{
transform.rotation = Quaternion.Euler(0,0, Mathf.Sin(Time.time * 2) * 60);
}
if (Input.GetMouseButtonDown(0))
{
stationary = false;
myBody.velocity = new Vector2(transform.rotation.z , 10);
}
}
The code works, but the object always move up instead towards the direction it's facing, how to fix that?
Comment