Pointer Lock Controls

Hello community,

I have question regarding camera rotating like in a first person shooters. With mouse event I get just delta movement of a mouse, but it works only if mouse moves in the screen and not out of it as it should in FPS games. I found that three.js have this controls out of the box:

Does Cocos Creator has something similar, or someone has an example of how to achieve this?

Thank you very much! :slight_smile:

I can ask engineering. What version of Creator are you using?

I think you may need this, you see if it is what you need

Thank you for the project, I will look at it right away.

Thank you very much! I’m using version 3.3.1 :slight_smile:


I got the solution by editing @muxiandong example like this:
FirstPersonCamera.ts.zip (1.7 KB)

This is how the demo looks:

On the click on screen, we get pointerlock, with esc be unlock the pointerlock. There is problem if try to lock the pointer right after we unlocked it we get: The user has exited the lock before this request was completed. As I understood we get this error as of security reasons, so the app could’t freeze the user with constantly locking him. This could be avoided with better UX. Hope this would be helpful, and if someone have suggestions on how could I do it better I would really like to improve my skills :slight_smile:

1 Like