# Godot 4.1
extends RigidBody2D
var node0
var target
func _process(delta):
follow_mouse()
func _input(event):
if InputEventMouseMotion:
target = get_global_mouse_position() # Get the mouse's global position
# Follow the mouse
func follow_mouse():
self.position = target # Sync the node's position with the mouse's positionGodot - Making a Rigid Body Follow the Mouse
·43 words