My value is updating automaticly without me doing it :(


Im trying to bypass some random camera movement method that is secretly moving my cam in SimpleGame.

Now, I do it by doing this:

If im holding down the right mouse button then the camera cant turn.

So i got this value oldCamVec.

Its being put to the current cam direction unless im holding down right mouse button.

If I DO hold down the right mouse button then it just sets the cameras direction to oldCamVec

Still! I can move around the camera and all!

Help please, Im sorry If im spamming with questions but Im really stuck in this camera direction subject…

Heres my code:

private void updateMouse() {
      boolean state = MouseInput.get().isButtonDown(0);
        if (state == true){
        if (MouseInput.get().isButtonDown(1)){
           mouseClicking = true;
           cam.setDirection(oldCamVec);//MouseInput.get().setCursorPosition(display.getWidth()/2, display.getHeight()/2);
        } else {
           System.out.println("Not clicking!");
           mouseClicking = false;

Its called every update in SimpleGame
And it says Not Clicking! only when Im not clicking so it is working..
Still not...

All help is appriciated :)

If you're using SimpleGame (which can probably be considered a game for testing) you're using a FirstPersonHandler, which has a MouseLookHandler to handle mouse look.

If you want to require a button to be pressed while moving the camera you could try this in your simpleInitGame():

//Require a button press to move the camera
//Set button to right mouse button

If you want to do it the other way around...perhaps you could set your own MouseLookHandler with your own MouseLook class that implements the following edited method instead of the normal one (a very minor change):

     * <code>performAction</code> checks for any movement of the mouse, and
     * calls the appropriate method to alter the camera's orientation when
     * applicable.
     * @see com.jme.input.action.MouseInputAction#performAction(InputActionEvent)
    public void performAction(InputActionEvent evt) {
        float time = 0.01f * speed;

        if(!buttonPressRequired || !MouseInput.get().isButtonDown(mouseButtonForRequired)) {
            if (mouse.getLocalTranslation().x > 0) {
                event.setTime(time * mouse.getLocalTranslation().x);
            } else if (mouse.getLocalTranslation().x < 0) {
                event.setTime(time * mouse.getLocalTranslation().x * -1);
            if (mouse.getLocalTranslation().y > 0) {
                event.setTime(time * mouse.getLocalTranslation().y);
            } else if (mouse.getLocalTranslation().y < 0) {
                event.setTime(time * mouse.getLocalTranslation().y * -1);


Also setting the above variables.
It might also be an idea to switch to extending BaseGame yourself or using StandardGame with GameState's.
Then you can implement only the parts that you want in your game the way you want them.

AHH that is how you do it!!

Thanks alot man :smiley: I had been looking in the super classes and found that FirstPersonHandler

but I didnt know how to access it…

Thanks for sharing your awsome java skills :stuck_out_tongue: