I'm looking for the best way to enable and disable player input

I’m looking for the best way to handle enabling and disabling player input from a camera controller (universal camera).

Hi again, i73. I would say attach/detach is the best/easiest way… but you can also add/remove items from camera.inputs, too, I think. You can also experiment with scene.activeCamera and scene.activeCameras.

Others may have other ideas… stay tuned.

1 Like

Agree, attach/detach is designed for that goal

A good read: Customize Camera Inputs - Babylon.js Documentation

1 Like

Thanks so much guys, I just had a chance to come back to this, if I’m not mistaken the attach/detach to me seems like it’s not the proper way (counter intuitive), I understand we’re all working with what we have. Specifically I’m not looking to detach controls just to stop invoking controller functions, but I understand if there’s no inputs.SetControls(false); then this is the best way.

But I might be a little confused FreeCameraInputsManager looks like it contains a touchEnabled property so I guess I could set that?

Just to confirm when the game is paused I want to disable keyboard movement, and for mobile touch input on the joysticks (still able to click buttons in the scene) I would want to do this?
GameSystem.mainCamera.inputs.detachElement(//What element do I set here?);


And when they go to unpause:
GameSystem.mainCamera.inputs.addKeyboard();

Just want to make sure I’m doing this properly.

Oh, all of a sudden… we have jumped from…

to…

:slight_smile: You want to disable touch, and still keep touch enabled, huh? yuh, yuh, yuh… you started drinking very early today, didn’t you? :wink:

In general, you want to disable almost everything… except the method to un-pause, right?

A detached camera… cannot pick/click a button… on mobile, correct? (I’m not sure.)

For desk/lap-tops… what? Spacebar or enter or “p” key, to un-pause, right?

So you have at least two avenues of input listening… to “filter” when paused… but not completely block-off. All possible input devices… MUST be able to press that un-pause GUI button, or type the un-pause keypress. Sound right? All other inputs… must be filtered-away.

I have no idea how to do that… but it sounds “custom”, doesn’t it? There HAS TO BE a channel to the un-pause function… from more than one kind of input device. hmm. Aren’t I helpful? heh.

1 Like

I lol’ed, sorry I should have been more specific, I’m scattered around so much it’s hard for me to have the time these days to coherently express my thoughts.

For PC browser I just need to disable keyboard (player movement when UI is on the screen / have a pause and unpause button ) and for mobile I guess now I can add a isPointerBlocker for the code, does my example look correct?

1 Like

:slight_smile: I’m just having fun with ya, i73, as you know.

Which example?

I haven’t seen one lately… but then again, I started drinking 2 days ago. (just kidding).

I don’t have any mobile devices nearby, atm. isPointerBlocker? Who taught you that? Use it on the entire advancedDynamicTexture, to make it “pointer/touch stupid”? That’d be cool. hmm. errr… noo… that would block the un-pause button. hmm.

I have nothing to contribute, here. Not enough experience in this subject, so feel free to teach us (me) what you learn/decide-on… I could use the knowledge. (thx)

Now that I’ve had some deeper thought into this, I’m thinking for the mobile side I’m going to create a window that’s 100% width and height and inside that I’ll add a controller with pointerblocked enabled (not allow the user to click on any elements outside the current UI)

So that leaves the desktop browser, specifically the enabling / disabling of the keyboard that leads me back to my reply I made 2 hours ago, asking what element to disable :slight_smile: and if that’s the best way to handle this process.

Probably…

freeCameraKeyboardMoveInput

shrug