- Home /
Use lerp or translate
When making an object (NPC) go from point A to point B (2d), what are the advantages/disadvantages of using lerp() as opposed to translate()? The same question goes for slerp() and rotate().
Answer by Bob5602 · Jan 17, 2011 at 02:24 PM
The difference is, for instance in rotate, one takes into account the target, the other does not. with Rotate() you can rotate some degrees every time its called, with slerp you can rotate some "max" degrees toward a new rotation. If you are just rotating for the sake of rotating (such as a spinning pick-up) I recommend using rotate, or if you just want your object to move forward, use translate. If you want to move from a point to another point, use lerp. Make sense?
One concern I have with translate/rotate is that it when I check to see if I have reached the destination point, I could 'miss' it since we are called every frame (not every point would get checked).
Honestly, just use lerp if you are moving an object linearly from point A to point B, and then use something like LookAt to get the rotation right.
Also remember Vector3.$$anonymous$$oveTowards for moving, Quaternion.RotateTowards for rotation in 3D, and $$anonymous$$athf.$$anonymous$$oveTowardsAngle for rotation around a single axis. These also take a target but just move with a constant speed or rotation towards it.
Your answer
Follow this Question
Related Questions
Rotating object around Z axis with lerp/slerp 1 Answer
Use Lerp to rotate object 2 Answers
Rotation with RotateAround 2 Answers
[QuaternionSlerp] Lookback script 1 Answer
How do I translate around a circle? 3 Answers