const joystickCamera = new FreeCameraVirtualJoystickInput();
useEffect(() => {
if (cameraRef !== null && cameraRef.current !== null) {
const camera = cameraRef.current as UniversalCamera;
if (isJoystickEnabled && currentScreen == ScreenName.None) {
camera.inputs.add(joystickCamera);
} else {
camera.inputs.removeByType('FreeCameraVirtualJoystickInput');
}
}
}, [isJoystickEnabled, currentScreen]);
i m using the above code to enable and disable the joystick controls.
but in case i m using the controls (i.e my fingers are touching the screen) and they get disabled while still in use, the puck images get stuck on screen, and new images instantiate when enabled again, not happens in case they are not in use.
pucks marked 1 and 2 on screen are stuck but 3 is the current in use.