- Home /
Move In Circle relative to rotation.
I have the following...
timer += Time.deltaTime * speed;
float x = Mathf.Cos(timer) * width;
float y = Mathf.Sin(timer) * height;
transform.position = new Vector3(transform.position.x + x, transform.position.y + y, transform.position.z);
This moves the gameobject in a circle, but no matter which way the object rotates it will always spin in the same direction.
I would like the direction its spinning to be relative to the rotation it has.
Anyone have any thoughts on how to achieve this?
Thanks!
Comment
Best Answer
Answer by andrew-lukasik · May 25, 2021 at 11:53 PM
transform.position += transform.rotation * new Vector3( x , y , 0 );
Your answer
Follow this Question
Related Questions
Creating Objects In Circle Starting at the top. 0 Answers
simulate a circle move 2 Answers
Move object in an arc 3 Answers
Trigonometry help? 1 Answer
Raycast moves away from object when object is rotated. 1 Answer