How to ease rotation when using 'look_at'?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By brylie

When using the look_at method on Node2D, the node is rotated immediately. This is somewhat unnatural, and would be nicer as a smooth transition. How can I smoothen the rotation when using Node2D.look_at()?

:bust_in_silhouette: Reply From: DodoIta

I don’t think you can smooth it using look_at() but, knowing the starting and final angles of rotation, you could do that using a Tween and by calling interpolate_property on the rotation property of your node.
That way you get to specify the time and the easing methods to better tweak the result.

Cool. Great suggestion!

I also added an issue on GitHub, where we can discuss improving the expressiveness of the look_at function with an added ‘tween’ argument.

brylie | 2018-03-17 08:24

:bust_in_silhouette: Reply From: Borgir

you can use some null (dummy) object like Position3D or 2D … make look_at() and then lerp between node and null object.