UI Problems with pointerlock


I have a sample project here where I created a UI menu linked to a fps script scene.

I have 3 problems that I could not solve that causes errors with the pointerlock controls.

Problem 1: When pressing Escape to bring the pause menu inside the game scene if I press continue quickly sometimes the pointerlock will not enable as you can see in the video below on the second try.

Problem 2: When spam clicking around the canvas in when the game is paused I disable the movement and camera scripts however sometimes the camera moves randomly please see video below

Problem 3: Please see video below when going to main menu from the game scene the pointerlock enables in the main menu for some reason I do not know why. I tried to disable it always on the main menu but for some reason that does not work.

Maybe the solutions is simple but I think I confused my self too much and cannot fix these errors for some reason. I tried using application events to make it better but I could not get this to work with my limited knowledge on events. Thanks for any help.

Hi @nasjarta! Is line 25 of your pause-menu script correct?

Hi Albertos yes looks like I made a typo instead of this.pause variable I put this.menu. When changed the problems above still happen.

I see you didn’t fix this yet and I am currently unable to open te menu.

1 Like

Hello Sorry I have fixed it now.

For problems 2-3 The pointerlock function inside the camera script is interfering with the other scripts but If i delete that function it fixes those issues but then I can not use pointerlock again if mouse is on the screen.

Why you don’t have a statement there to check if the game is paused? I would make this.pause global so you can acces it in every script. Then you can do something like below.

Camera.prototype.onMouseDown = function(event) {
    if (!pause) {
1 Like

Hello sorry I already solved problems 2-3 thanks for your solution Albertos. For problem 1 there is a small delay between when you click and when the pointerLock is enabled.

Please can you mark this solved thanks