[SOLVED] Issue With FPS Movement

I’m using a slightly modified fps movement tutorial script and it works great but there are 2 issue I need help with.

  1. I can’t move straight forward it just stops in its tracks

and

  1. When I leave the level and go back to the main menu it won’t let me press any button until I refresh the page

If anyone has any idea on how to fix these issues I’m all ears.

  -Your Pal
         William Boersma

Hi @WilliamBoersma31! Can you share a link of your project please?

Sure
Here Is the Project: https://playcanvas.com/project/749856
And Here Is The Specific Script Causing An Issue: https://playcanvas.com/editor/code/749856?tabs=40394915

Are the problems on a specific scene or menu, because I don’t experience the problems you describe.

I recommend fixing the error first as it distracts me from testing properly.

I know that is very distracting and I have no idea whats causing it.
as for the other issues I’m having the second one only happens when you start a level then back out by double clicking escape and number one seems to happen on random somtimes it happens sometimes it doesn’t.

I found out that it has to do with pointer lock.

image

I see you use it in different scripts.

image

Try to disable everything you don’t want to use to see if it solve the problem.

it seems to be cause by locking the pointer while the pointer is locked is there any way to check if it is locked?

This has probably also to do with the enablePointerLock problem. Every time you click you get that error message and that probably block the input, but I’m not sure. I don’t think you want to enable pointer lock when you click in the menu scene?

I know that script just won’t unload

What does 2, 2 in that lines?

2,2 is centre of the screen

I don’t have the feeling that does anything? Can you try it without?

ok

Well it no longer centres the mouse but I made an edit that makes it no longer necessary.

But I’m still having issue number 2 it still lock in the menus.

Make sure you don’t enable pointer lock when you click on a button. Maybe you can add an if statement to prevent this.

do you think I could have it only enable pointer lock when this.app.root.name == root and then change the root name in the menus? or would that make it unable to find the root.

never mind I tested it and i didn’t work

Ok So I Fixed It. But How Do I Fix Issue 1?

Can you explain issue 1 a little better please?