I feel like I am being really stupid here, but is there an easy way to have an enemy follow you in a curved motion by adjusting the steering force?
Here is my basic code to have a sprite follow the mouse around the map, but as expected it always follows it in a strait line. How would you go about adjusting the steering force to have the character follow the mouse in a curved motion, in particular when there is a change of direction, so the change of direction is more natural and less snappy.
func _physics_process(delta):
var desired_velocity = (get_global_mouse_position() - global_position).normalized() * MAX_SPEED
var steering_force = desired_velocity - velocity
velocity = (velocity + steering_force).limit_length(MAX_SPEED)
position += velocity * delta
Here is an example drawing. If I were to drag my mouse along the strait line, how could I get the character to follow me in a way more similar to the curved line. (Apologies for my awful art)