I am working in GDScript, and I'm trying to get the player to aim their weapon in the direction of the mouse cursor. The look_at()
function is great, but it's not the smooth movement I'm looking for.
So, instead I've been experimenting with the lerp()
math operation to make it smooth... but its very jittery and buggy movement which is obviously not ideal.
func _process(delta):
`rotation_degrees = lerp(rotation_degrees,rad2deg(get_angle_to(get_global_mouse_position())),aim_speed)
` 1 See the image of my code here.
I can't work out if I'm doing something really stupid as I'm fairly new to Godot. Any help would be massively appreciated!