How to make a slow out rotation?

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

I’m rotating a 2dnode by using 'rotation += speed * delta '. The rotation will happen only if I pressed the space button. The problem is I want to make a slow out motion, in which the object will stop rotating after a short period and its speed will gradually decrease to zero.
Is there any good way to do that?
Thanks for the help. :slight_smile:

oh, I think I found the problem. I put a while loop into the _process function.

dethland | 2020-12-02 07:15

:bust_in_silhouette: Reply From:

Maybe it’s a little rough, but try animating the Node2D by rect_rotation in a loop and then doing something like:

func _spacereleased()
    var slow = 1
    while true:
        yield(get_tree().create_timer(0.1), "timeout")
        slow = slow - 0.1
        $AnimatedPlayer.playback_speed = slow