Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
jonathantopf's avatar
jonathantopf
Honored Guest
5 years ago

Unity Cursor Locking & mouse delta issues

I'm trying to build a simple FPS with a mouse connected via the USB port to control the crosshair using unity but I'm finding that the mouse values I receive get clamped.

I initialize cursor controller like so:

void Start ()
{
    UnityEngine.Cursor.lockState = CursorLockMode.Locked;
}


And retrieve the cursor delta with this line
var delta = new Vector2 (Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
The behavior I'm seeing is that the delta is returned fine to begin until I hit the edge of an invisible wall At that point the delta values become zero in the axis of the wall I hit.

When I log UnityEngine.Cursor.lockState out on a device build it says that it's no longer locked.

It seems to me that two things could be going on
- The cursor is not being locked, and the feature is not supported
- Something is unlocking the cursor lock

Can anybody shed any light on what's going on here?
No RepliesBe the first to reply