Override Default Controls

Sorry if the answer to this is clearly in the documentation, but having worked through the Hello Input System and Hello Collision tutorials I don’t see it.

By default, Simple Application provides default camera controls for WASD, mouse movement, and the arrow keys. Is there a way to replace or override these default actions? If, for example, I wanted the arrow keys to function like the WASD keys, and vice versa, how would I go about handling that?

When I try adding a new mapping onto the up arrow key, it seems to combine the behaviors of moving forward and moving the camera up. Do I just need to somehow prohibit the default camera up behavior? If so, how?

Remove the normal fly by cam (remove its app state) and add your own implementation of input → camera mapping.

FlyByCamera is really just a mapping of wasd+cursor keys to camera flight. It’s not configurable or anything but it’s easily duplicating with different mappings.


Basically as an exercise I’m trying to modify the Hello Collision tutorial to map navigation onto the arrow keys (which is working fine), but still have the same camera behavior mapped onto mouse movement (i.e. looking around when scrolling).

To replicate the mouse behavior as you suggest, I looked at the source of FlyByCamera and attempted to replicate the relevant logic. I had HelloCollision implement AnalogListener, disabled the flyCam, added new mappings and listeners for mouse input along the X and Y axes, and added these two methods from FlyByCamera:

public void onAnalog(String name, float value, float tpf) {
if (name.equals(“CamLeft”)){
rotateCamera(value, initialUpVec);
}else if (name.equals(“CamRight”)){
rotateCamera(-value, initialUpVec);
}else if (name.equals(“CamUp”)){
rotateCamera(-value, cam.getLeft());
}else if (name.equals(“CamDown”)){
rotateCamera(value, cam.getLeft());

protected void rotateCamera(float value, Vector3f axis){
Matrix3f mat = new Matrix3f();
mat.fromAngleNormalAxis(rotationSpeed * value, axis);

    Vector3f up = cam.getUp();
    Vector3f left = cam.getLeft();
    Vector3f dir = cam.getDirection();

    mat.mult(up, up);
    mat.mult(left, left);
    mat.mult(dir, dir);

    Quaternion q = new Quaternion();
    q.fromAxes(left, up, dir);


It sort of works, though the behavior is not ideal (looking up and down seems restricted to about a 90 degree arc, and side-to-side is also restricted). The problem might be the initial value of the initialUpVec? HelloCollision initializes the player like so:

CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
player = new CharacterControl(capsuleShape, 0.05f);
player.setPhysicsLocation(new Vector3f(0, 10, 0));

I seem to get the best behavior when I initialize initialUpVec with the same vector that the player is initialized, but it still doesn’t work quite right. Thanks in advance for any input.

FlyByCamera works… your code doesn’t. Might be time to investigate what is different.