Default Mouse Look Script

Hello All,

I have a 3rd person camera on the go with the stardard MouseLook script on my player controlling the X axis and a standard MouseLook script on the camera controlling the Y axis.

What I need is for the cursor to ALWAYS be centered in the middle of the screen. Can this be done? If so can you help me with some example code or point me in the right direction please?

Many thanks in advance!

Given that locking the mouse cursor in the webplayer is problematic, one possibility you may want to consider is having a crosshair that operates separately from the mouse cursor in your 3rd person mode, such as by drawing one in the OnGUI() event.

Use "Screen.lockCursor = true".

Use "Screen.lockCursor = true". In standalone games you can do this anywhere, and it should work.

In a webplayer you are not allowed to lock the cursor before the user has clicked somewhere inside the webplayer area, so it's better to set Screen.lockCursor = true whenever you get a mouse-down (if you still want to lock the cursor).

Note that even if the cursor is successfully locked, it will be unlocked again if the user presses ESC. This is why it's a good idea to lock it whenever you get a mousedown. This way the user can free the mouse by pressing ESC, but then get the mouse locked again by pressing inside the webplayer area again.