Reputation: 45
I am using Pointer Lock Controls for my project and found a bug.
If player is pressing any of directions keys on keyboard and in the same time he presses esc button (to turn of Pointer Lock Controls), camera is still moving in a background, although it is not visible. Later after player clicks mouse button ( to turn on Pointer Lock Controls), camera is in another position.
How to fix that? How to stop camera movement when controls is turn off?
This can be seen in Pointer Lock Control example - https://threejs.org/examples/misc_controls_pointerlock.html
Upvotes: 0
Views: 512
Reputation: 11
Try the following.
declare global varibale:
let isPaused = true;
Then, when player presses play button, isPaused
is set to false
After that, make following changes:
var onKeyDown = function(event){
if(isPaused == false){
//remaining code here
}
}
Make sure to set isPaused
to true
when game is paused.
UPD: Probably should make same changes to onKeyUp
Upvotes: 1