Input Trigger wont work

Hi I just started to play a bit with the examples and just after the first edit I ran into a problem.

I want to add moving forward and moving backward to the HelloInput example.

This is my initKeys():

[java]private void initKeys() {

// You can map one or several inputs to one named action

inputManager.addMapping(“Pause”, new KeyTrigger(KeyInput.KEY_P));

inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));

inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));

inputManager.addMapping(“Forward”,new KeyTrigger(KeyInput.KEY_W));

inputManager.addMapping(“Back”, new KeyTrigger(KeyInput.KEY_S));

inputManager.addMapping(“Rotate”, new KeyTrigger(KeyInput.KEY_SPACE),

new MouseButtonTrigger(MouseInput.BUTTON_LEFT));

// Add the names to the action listener.

inputManager.addListener(actionListener, new String[]{“Pause”});

inputManager.addListener(analogListener, new String[]{“Left”, “Right”, “Rotate”});


and I added this to the AnalogListener:

[java]if (name.equals(“Forward”)) {

Vector3f v = player.getLocalTranslation();

player.setLocalTranslation(v.x, v.y, v.z + valuespeed);


if (name.equals(“Back”)) {

Vector3f v = player.getLocalTranslation();

player.setLocalTranslation(v.x, v.y, v.z - value


However the Box does not move. I did set the speed to a factor of 10 and left/right moves much more fast than the default cameramovement you got in simple app. But at forward and back I got the same speed. To be sure I added a print of the name that was given after the if clause:


On left and right, it prints “Left” and “Right”, but forward and back does not give anything.

Whats wrong?

lol wow I just saw the problem looking at my own posting.

I forgot to add the listener…

… nvm -_-

1 Like