WarpCursorPosition problems

Hello guys, I am trying to control the cursor with a gamepad, using the WarpCursorPosition() function.

The code I have works in the Unity editor, but when it comes to the actual build, there are problems.

Vector2 ballpos = GameObject.Find("Ball").transform.position;
Vector2 screenpos = Camera.main.WorldToScreenPoint(ballpos);
Mouse.current.WarpCursorPosition(screenpos);

(Please see screenshot). I am wanting the cursor to move onto the green ball, but instead it appears where the white cross is. It seems like it is not taking into consideration the black bars surrounding the play area, and the Y axis also seems to be inverted.

Any help appreciated! :slight_smile:

More info. The game is running full-screen at a resolution of 1920x1080. But I am using an ultra-wide monitor, so there are black bars on the sides. Is there a way Unity can handle this?

The WarpCursorPosition() function is giving me results as if the game was running on the left hand side of the monitor, instead of in the centre.

Update. This problem occurs when I have set a specific resolution - e.g. Screen.SetResolution(1920, 1080, true);

If I don’t do this, and let the game run in whatever resolution it chooses, the problem goes away.

Could be considered a bug?