Point an object towards a point slowly

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

Hello everyone,


I am looking for a way to slowly rotate the triangle in the video (which is a node2d with a polygon2d inside it). If I use look_at(global_mouse_position()) the the change in rotation is instantaneous. I am trying to emulate the steering behaviour following this video, it uses p5js for drawing on the screen, and the code for the tutorial is here, just not able to emulate the float theta = velocity.heading2D() + PI/2; behaviour.

Here’s the code for the entire scene, code

Here’s what i tried newly and gave me weird results

var dir = g_velocity.angle_to(location)
rotation = lerp_angle(rotation, dir, 0.1)