I've been told that
I can't find out how to rotate smoothly between fixed positions. I can rotate to the angle I want instantly
using Note:
derHugo 75k9 gold badges67 silver badges103 bronze badges asked Nov 3 at 19:21
First of all Then in general your jitter might come from overshooting - you might be moving further than the distance between your player and target actually is. You can avoid that bit by using
Then you can simply apply this same concept also to rotation by going through
the equivalent
answered Nov 4 at 11:00
derHugoderHugo 75k9 gold badges67 silver badges103 bronze badges 1 You can go one step further and use a tweeting library to tween between rotations. DOTween With that you can call it like this:
Or even add callbacks.
If at some point you want to cancel the tween yuou can save it on a variable and then call answered Nov 3 at 21:01
HorothenicHorothenic 6806 silver badges12 bronze badges 9 So, you want to animate the rotation value over time until it reaches a certain value. Inside the Update method, you can use the Lerp method to keep rotating the object to a point, but you will never really reach this point if you use Lerp. It will keep rotating forever (always closer to the point). You can use the following:
So, if the distance between the current object angle and the desired angle is greater than 0.01f, it jumps right to the desired position and stop executing the Lerp method. answered Nov 3 at 19:41
2 |