How to add a rotation speed limit when character look at mouse global position

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

Hi, I’m Konishi, I’m learning Godot Engine these days. Recently I encounter a problem.

I am making a top down shooting game, the character holding the weapons and always follow the mouse global position of players. However, sometimes I find this interaction respond too fast.

How can I add a rotation speed limit so I could let it slow down a little bit.

Thank you for reading:)

:bust_in_silhouette: Reply From: Enfyna

You can try to use lerp.

func _process(delta):
    position = position.lerp(get_global_mouse_position(),0.01)

I attached this code to a node and when I start the scene it will follow my mouse with a delay.

:bust_in_silhouette: Reply From: stormreaver

I always use a sensitivity factor to solve this:

character.rotate(axis,angle * sensivity), where sensitivity is a floating point number (usually between 0.0 and 1.0).