FlyCam ZoomIn/ZoomOut

I’m looking to disable the flycam ZoomIn/ZoomOut mappings - and haven’t had any luck.

I’ve searched the forums and looked at the inputmanager/flycam source and everything leads to calling:
[java]inputManager.deleteMapping(“FLYCAM_ZoomIn”);
inputManager.deleteMapping(“FLYCAM_ZoomOut”); [/java]

But this fails with
[java]java.lang.IllegalArgumentException: Cannot find mapping: FLYCAM_ZoomIn[/java]
and
[java]java.lang.IllegalArgumentException: Cannot find mapping: FLYCAM_ZoomOut[/java]

Also,
[java]this.getInputManager().hasMapping(“FLYCAM_ZoomIn”)[/java]
returns false

This is the case with my full project and a completely empty project, both SimpleApplications, with the code above being called in SimpleInitApp()

Any ideas?

unfortunately you can’t call that in simpleInitApp anymore, search the forum/docs for FlyCamAppstate. It is because the flycam is initialised in an appstate, where the following is called:

[java]flyCam.registerWithInput(app.getInputManager()); [/java]

so the mappings won’t be available until the next frame.

Either:
Make your own specialised Flycam, FlyCamAppstate or create another appstate and do your initialising inside the initialize method and attach that in simpleInitApp. There may be other ways

Other option is to create an initialize flag and do this during the first frame pass.

[java]@Override
public void simpleUpdate(float ftp) {
if (!initialized) {
extendedInitializer();
initialized = true;
}
}

private void extendedInitializer() {
inputManager.deleteMapping(“FLYCAM_ZoomIn”);
inputManager.deleteMapping(“FLYCAM_ZoomOut”);
}[/java]

Or something similar using:

[java]inputManager.hasMapping()[/java]

It’s a bit on the sloppy side, but should work.

yeh, that is a possibility (and i’ve done it myself ^_^) but then you would be checking for something the rest of the whole game session which is never gonna happen again. While it is a cheap operation, I’d prefer something like an initializing appstate/control, which you can then detach afterwards.

You can also move everything you have in simpleInit and simpleUpdate into a “MyGame” app state and leave your SimpleApplication clean. You don’t have to have a simpleInit or simpleUpdate at all in that case (unless you want to attach the state in simpleInit(). And the camera will have been initialized by the time the app state’s init is called presuming it was added after fly cam’s app state.