- Home /
Question by
Steeban · Sep 30, 2017 at 07:55 AM ·
2drotationrigidbody2dsmoothinterpolation
How to rotate an RigidBody2D object to an angle and get back to the previous position in the smooth way?
I need to implement a boat movement like below. How can I achieve a smooth rotation to a side and come back straight. I am beginner. Please refer the image.
untitled-2.jpg
(54.4 kB)
Comment
Answer by hlw · Sep 30, 2017 at 10:35 AM
If i remember right, you should use Slerp (there are tutorials about how to use it correctly).
If this isn't smooth enough, then you need to set the "base rotation" of the object, then set it's actual roation each frame, multiplying base rotation by Mathf.Sin(Time.time) and dividing it by a float of your choice . (something like that, i used it only once a while ago). Actually you can use any mathematical curve as long as it goes smoothly from 0 to one.