Disable pointer lock in main menu (third person)

Hello! I want to disable the pointer lock of the cameramovement script when the main menu is displayed. How do I disable it and enable it when I start the game?


Hi @churiboii,

You can use the following methods to enable and disable mouse pointer lock on demand:

I tried using the code, this.app.mouse.disablePointerLock();

But it does not work. I want to make it disable when I have the ui screen :frowning:

Hi @churiboii! Where do you enable the pointer lock? Make sure it doesn’t override your disabling.

I did enable it in my CameraMovement script

I did try enabling it in the gameUi script, it kinda worked. But when I try pressing ESC, I cant seem to enable the pointerlock

As far as I know, it’s a default option of the browser to disable pointer lock with the ESC key. I don’t think you can change this. Why do you want to enable pointer lock with the ESC key?

No, I meant when I put the enable pointerlock on gameUI script, I can disable it when an UI screen appears and enable it when playing.

However, while playing and suddenly wanted to switch tabs, you have to press ESC to disable, right? But I cant seem to go back to enabling the pointerlock unless I open the UI and close it.

Other way I tried is putting the command in my CameraMovement script. However, I cant disable it when an UI menu appears

You need an if statement here, to check if your menu is disabled.

if (menuEntity.enabled === false) {