How can I deactivated mouse action and then activated it when camera.position.y < x

Hello everyone

I use the following code to detach the mouse actions at the beginning:
camera.inputs.attached.mouse.detachControl();

and then I use the following code to activate the camera for a specific camera position:

  scene.registerBeforeRender(() => {
    ...
    if (camera.position.y < 2000)  camera.inputs.addMouse(true);        
  });

but I can’t get the desire result, is it possible help me know how can I do it?
here is my PG:

I think the line you are looking for instead is camera.inputs.attached.mouse.attachControl(true); :wink:

1 Like

Hey @msDestiny14 Thank you so much :pray: :pray:
can I ask another question? now I can change the camera angle when the camera.position.y is smaller than 2000, but when I go to the position bigger than 2000 then I want to disable the mouse and get back to the default input which was detach, but it doesn’t work properly. I mean I just want to attach mouse to the camera in camera.position.y<2000.

here is my PG: https://playground.babylonjs.com/#X2ULQN#57
is it possible to see it?

You mean like this? I would also recommend snapping the camera back if you’re going for map look.

2 Likes

Yes this is that I like to build, it’s great, Thank you so much @msDestiny14. :pray: :pray: :pray: