- Home /
Transform position of an object at particular angle/direction
I have an object that oscillates. On click it stops at an angle. I want to transform its position to a distance at the same angle.
red Curve directs the movement and doted line indicates required movement of object to a distance e.g. 10
looking for more precise answers. Thanks for the help though.
please be a little precise. i m having same problem, and being new to unity cant go around.
Answer by Berenger · Nov 29, 2012 at 11:33 AM
If the objects is rotating for that oscillation behavior, you can modify transform.localPosition, or use Translate (which is local by default).
Answer by loopyllama · Nov 29, 2012 at 11:38 AM
Vector3 newPosition = positionOfOscillatingObject + forwardVectorOfOscillatingObject * distanceToMove;
Answer by vardhan · Nov 30, 2012 at 10:08 AM
can you please give more precise answer. i m new to unity and dont know much about.