- Home /
Move an object relative to another object's axis
How would I do this? I figured out a way of getting the distance I need it to move by, I just don't know how to make it move along the other object's axis. Is there a way of doing this without making it a child of that object? Thanks
I tried something like this but it doesn't work:
transform.position = Mathf.Lerp(transform.position, otherObject.forward * distance);
This question is very unclear. Give more details on what you're trying to do - move parallel to otherObject.forward, move from otherObject to distance units in its forward direction, move from where the object is to a distance distance ahead of otherObject... Explain what's your objective
Answer by wolventoad · Aug 21, 2012 at 02:55 AM
Maybe you are moving along the object's world axis.
The position showed in your inspector, that's local axis. try use 「otherObject.localPosition + Vector3.forward * distance」, maybe can help you.
Good luck.
Well...confused. Could you tell me what situation you are now facing?
Your answer
Follow this Question
Related Questions
Touch and move in any axis 0 Answers
Vector 3 - move on only one axis 0 Answers
Objects aren't moveable? 1 Answer
Find Distance on Single, Relative Axis? 1 Answer
SmoothDamp not working? 1 Answer