How can you make the mouse follow the player?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Natey214

Hello, I am trying to make it so that the mouse is always on the player characters position with the command

Input.WarpMousePosition(this.Position) within the _Process method of the player’s script.

it is then released on the press of a key.

This works except when using the 2D camera node which causes the mouse to be offset based on where the player is and the size of the screen.

I fixed this issue when making an object follow my mouse by using the GetGlobalMousePosition(); however, I can’t find a global option for WarpMousePosition. Is there one? Or another way to accomplish what I’m looking for?

How’s your code set up? Is this camera a child of player or a node independent of the player?

MisterMano | 2021-10-30 03:19

The code is

if (Input.IsActionPressed(“ranged_wish”))


void ranged_wish()
fieldOfWish.GlobalPosition = GetGlobalMousePosition();
fieldOfWish.Scale = (new Vector2(0.1f, 0.1f));

The camera node is independent of the player and child to the main scene.

Natey214 | 2021-10-31 15:52