FlyCam Default InputManager/Mappings wont delete?

Hello all!

I have recently started using JMonkey and it seems that using the “FlyByCamera” is the best way to move around a scene.

However I am finding it impossible to get rid of the default inputs, but making my own in the process. I would like to keep the Mouse drag movements though.

I tried using

    inputManager.clearMappings();
    inputManager.clearRawInputListeners();
    inputManager.update(Float);

But it wont clear at all.

I’ve seen a google document(from awhile ago it seems) showing these mappings.

inputManager.deleteMapping(“FLYCAM_Left”);
inputManager.deleteMapping(“FLYCAM_Right”);
inputManager.deleteMapping(“FLYCAM_Up”);
inputManager.deleteMapping(“FLYCAM_Down”);

       /* "FLYCAM_StrafeLeft",
        "FLYCAM_StrafeRight",
        "FLYCAM_Forward",
        "FLYCAM_Backward",

        "FLYCAM_ZoomIn",
        "FLYCAM_ZoomOut",
        "FLYCAM_RotateDrag",

        "FLYCAM_Rise",
        "FLYCAM_Lower"*/

but when I try to delete them, it gives me an error saying they “Don’t exist” https://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/core/com/jme3/input/FlyByCamera.java?r=5416

I’ve tired looking all over the web, and nothing. Anything would be greatly appreciated!

How about you try AppSettings.setUseInput(false); https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:appsettings

<cite>@Pixelapp said:</cite> How about you try AppSettings.setUseInput(false); https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:appsettings

Thanks for that, I meant I want to use other keys, but remove the one’s that are default. From the look of UseInput, that would completely get rid of everything.

Basically I’m looking to use the Mouse Movements already defined, but I would like to ONLY have forward and backward by using KeyInput.UP and Down. As well as the mouse clicking not messing with those(since it does by default).

Thanks again!

If you try to remove the mapping in simpleInitApp() then they don’t exist yet. FlyCam gets initialize in an app state after simpleInitApp(). You have a few options:

  1. remove the existing fly cam app state completely and just have your own camera handling.
  2. do your game logic in the initialize() method of your own app state instead of SimpleInit.
  3. some combination of both.

If you are curious, here is effectively what is in Mythruna’s simpleInitApp() and simpleUpdate() methods:

[java]
@Override
public void simpleInitApp() {
}

@Override
public void simpleUpdate(float tpf) {
}

[/java]

I override them just in case but I do all logic in AppStates because they are more modular and a better design overall.

2 Likes

Generally the jme cameras are there as starting points but are not expected to fully meet people’s requirements just because camera handling varies so much between games.

Take your own copy of FlyByCamera and modify it to get the behaviour you want.

@pspeed said: If you try to remove the mapping in simpleInitApp() then they don't exist yet. FlyCam gets initialize in an app state after simpleInitApp(). You have a few options:
  1. remove the existing fly cam app state completely and just have your own camera handling.
  2. do your game logic in the initialize() method of your own app state instead of SimpleInit.
  3. some combination of both.

If you are curious, here is effectively what is in Mythruna’s simpleInitApp() and simpleUpdate() methods:

[java]
@Override
public void simpleInitApp() {
}

@Override
public void simpleUpdate(float tpf) {
}

[/java]

I override them just in case but I do all logic in AppStates because they are more modular and a better design overall.

Sorry that I’m coming back to this months later, I put the application states to the end of my project.

I want to create my own FlyByCam inputs , and it’s kind of going well, but I keep getting that it tries to add the FlyByCam inputs multiple times.

My question is how exactly do I delete the FlyCamAppState from SimpleApplication? I have tried a few things with no luck.

It also seems that I could set the flyCam.Enable(false); but when I try that I have no luck. you said that it isn’t initialized in simple init, but I tried to add it to the update loop with also no luck, would there be a better place to do it, or would removing the appstate be the best choice? All I would then have to do is just have my own FlyCam class added to my new Appstate?

You also said to do the game logic inside your own appstate instead of simple app, so would you just add the appstate within the simpleinit when you’re done with it right?

Thanks!

@KonradZuse said: My question is how exactly do I delete the FlyCamAppState from SimpleApplication? I have tried a few things with no luck.

Did you try searching the forums? This has come up so many times I get tired of repeating the same answer.

The easiest way is to just never include it in the first place which you can do with the super() constructor. I will let you search the forum for “remove flycam” to see if you can find it. It will be a positive learning experience on forum searching.

@pspeed said: Did you try searching the forums? This has come up so many times I get tired of repeating the same answer.

The easiest way is to just never include it in the first place which you can do with the super() constructor. I will let you search the forum for “remove flycam” to see if you can find it. It will be a positive learning experience on forum searching.

I searched google and some answers popped up, but it seems to only show deleting certain mappings, is there a way to wipe it in one go?

When searching “the forums” I did find some more info, I saw one topic which mentioned the super constructor as well, but no code example, and I’m not 100% exactly what to do so I will keep on looking for the answer.

I had to go in the middle of my search and just returned.

Edit: Figured it out.