Reputation: 39
I got this to move an object in a circle:
currentAngle += Time.deltaTime * angularSpeed;
offset = new Vector3(Mathf.Sin(currentAngle), 0, Mathf.Cos(currentAngle)) * circleRad;
transform.position = fixedPoint + offset;
Is there a way to get the original currentAngle
(used to calculate a point) from a position on this circle, like backtrack the function?
Upvotes: 0
Views: 116
Reputation: 1197
The atan2 function is what you are looking for.
In C# it is available as Math.Atan2
, which takes double
arguments. In addition, Unity (which you are probably using given the code sample in your question) has Mathf.Atan2
which takes float
arguments.
Upvotes: 1