FreeCameraVirtualJoystickInput - joystick images stuck on screen

  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.

Could you reproduce that on the playground? Are there any exceptions thrown when that happens?

1.enable joystick with ‘z’ and while using the joystick press ‘spacebar’ to disable joystick controls.
2. enable joystick again with ‘z’ key u can see the old images stuck there.

Got it! And found the issue. I am working on a fix.

Quicker than I thought :slight_smile:

VirtualJoystick - Stop iterating when canvas is released by RaananW · Pull Request #13332 · BabylonJS/Babylon.js (github.com)

2 Likes