- Home /
Question by
a383338070 · Oct 19, 2017 at 03:48 PM ·
positiontranslate
How to translate an object correctly?
I am trying to let object A moves toward object B. I can get the direction vector by subtracting the position of A from the position of B so that I can use the function "transform.Translate". Now the problem is if I accidentally flip A , the local coordinate system will also be flipped, which results in A will move in another direction.
Comment
Best Answer
Answer by Kishotta · Oct 19, 2017 at 03:53 PM
You should specify which coordinate space you want to use when moving your object.
// Moves in the towardB direction in A's local space (which rotates with it)
transform.Translate (towardB); // Default "Space" parameter is Space.Self
// Moves in the towardB direction in world space and is unaffected by rotation
transform.Translate (towardB, Space.World);
Your answer
Follow this Question
Related Questions
Position Error in p30 lite - android 10 0 Answers
Translate Vector3 by Vector3 1 Answer
If click go up else pingpong movement (2d) 0 Answers
How do I translate around a circle? 3 Answers
Stop moving at the target position by using Vector3.forward 0 Answers