Wolfenstein-like keyboard navigation

I have an environment with lots of boxes and spheres. Now I want to restrict game movement to only use the arrow keys, not look up or down just move the camera forwards, backwards and rotate around the Y axis.

The left and right arrow keys do what I want with flyCam enabled but I want to replace KEY_W and KEY_S with KEY_UP and KEY_DOWN, somewhat like Wolfenstein where the player is always at same Y height, can rotate around Y and move forwards and backwards.

flyCam has to be disable to stop the default keyboard and mouse actions.

I have been able to do this with LWJGL projects directly by using the following to move forwards, backwards, left and right:

z += amount * Math.sin (Math.toRadians (rotationY + 90 * direction)); 
x += amount * Math.cos (Math.toRadians (rotationY + 90 * direction));

but I can not figure out how to navigate the camera with JMonkey.

grep-ed the jmonkeyplatform directory (-iRn) to see if I could find any reference to KEY_W or KEY_S and so figure out how it’s done but only binaries were returned.

Inside your application you can use those methods to get and set the camera rotation and position

First, don’t disable the fly cam… just remove it’s app state or don’t even include it. Search the forum for “remove flycamappstate” or whatever.

Easiest way to do what you want:
step 1: open FlyCamAppState and FlyByCamera
step 2: cut and paste into your own classes
step 3: rip out the stuff you don’t want, change key mappings.
step 4: done

…well, register your new app state with state manager instead of the old one.

thanks for your excellent and speedy reply !

Also thank you very much for your excellent and speedy reply !


I was able to scrape a few lines of code (and a solution) from here:

Best regards