Hi everyone, I have a problem with the code regarding "making the object move towards the mouse pointer". I followed the tutorial on godot official documentation but it didn't work. So I decided to do it without following the documentation but the problem is that when I click to make the object go to a given position, the object goes in that direction but it doesn't stop. Here is the code:
var dir = Vector2()
var speed = 200
func input(event):
if event is InputEventMouseButton:
dir = position.directionto(event.position)
func physicsprocess(delta):
moveandslide(dir * speed)