Set Mouse Position Unity

Set Mouse Position Unity

To set the mouse position to be at the position (0,0,0) in Unity, you can use the following code:

Vector3 mousePos = new Vector3(0, 0, 0);
Input.mousePosition = Camera.main.WorldToScreenPoint(mousePos);


This code creates a new Vector3 with the coordinates (0,0,0), and then uses the WorldToScreenPoint method of the Camera component to convert the world coordinates to screen coordinates. The resulting screen coordinates are then assigned to the Input.mousePosition property, which sets the mouse position.

Note that this will only work if you have a camera in your scene that is marked as the main camera (by assigning it to the Camera.main property). If you have multiple cameras in your scene, you will need to specify which one you want to use to convert the coordinates.