I have a character that the player controls. This character has a little friend that follows them around, but can be controlled by the player using the mouse. When the player presses a button I want the friend to detach and start following the mouse. To accomplish this I want to warp the mouse to the location of the friend, then allow the friend to start being moved around by the mouse.
Instead, when I hit the button to release the friend, the mouse warp warps the mouse by some seemingly constant offset to the left and up of where it should be by a wide margin and I can't figure out why.
func _process(delta):
if (Input.is_action_just_pressed("release_buddi")):
Input.warp_mouse_position(self.position)
# anchored is whether or not the friend should follow the player
anchored = false
if (anchored):
self.position = Vector2(filip.position.x, filip.position.y - 50)
else:
self.position = Vector2(get_global_mouse_position().x, get_global_mouse_position().y)