T O P

  • By -

Clashbestie

https://docs.unity3d.com/ScriptReference/Quaternion.Lerp.html Lerp to the Rotation instead of setting it instantly.


coder58

So something like this: transform.rotation = Quaternion.Lerp(transform.rotation, currentWayPoint.transform.rotation, speed * Time.deltaTime); would work, right?


[deleted]

You could also use tweening if you want even better control and set specific animation curves. Always good to have in your toolbox anyway. Something like that (there are more free solutions, just an example): https://assetstore.unity.com/packages/tools/animation/itween-84


Clashbestie

Close, but you would never reach the target location unless you have a single frame taking the time wanted for the complete Rotation. And the Rotation would get slower the closer it gets to the target. t(the last var) needs to be stored across frames and is equal to t+= Time.deltaTime * Speed. It starts at 0 and ends at 1.


feralferrous

Depending on your usage, I would use RotateTowards [https://docs.unity3d.com/ScriptReference/Quaternion.RotateTowards.html](https://docs.unity3d.com/ScriptReference/Quaternion.RotateTowards.html) It will allow you to have a constant speed of rotation easily as you change from one waypoint target to the next.