godot : sprite move to mouse position

in #godot7 years ago (edited)
const MOTION_SPEED = 350 # Pixels/second<br>
func ... <br>
    var m  = get_global_mouse_pos()
    var motion = Vector2(m.x-get_pos().x,m.y-get_pos().y)
    motion = motion.normalized()*MOTION_SPEED*delta
    move(motion)