Cursor isn't locked to window, isn't invisible [SOLVED]

I’m using a chase camera for my application, and it orbits the playable character. I can’t find any way to actually lock the mouse to the centre or hide it.
Every other thread seems to suggest turning off the drag-to-rotate, but that doesn’t change the visibility of it nor does it constrain it.

This is in the Eclipse IDE, with the latest stable release.

Solution for others:
You must detach the default FlyCam, as well

   private void setupChaseCamera(Node target) {
        chaseCam = new ChaseCamera(cam, target, inputManager);

The key part being stateManager.detach(). This removes all the default properties of the FlyCam that seem to overwrite the chase camera mouse settings

1 Like

Isnt there some method of inputManager which does that? inputManager.captureMouse() or something like that. I can’t remember right now.

I had tried that, but it didn’t work

Generally, and I mean that in it’s purest sense, you begin a game like so:

public class Main extends SimpleApplication {

    public static void main(String... args) {

        Main main = new Main();


    public Main() {
        super(new SomeAppState(), new SomeAppState2());

    public void simpleInitApp() {

        // initialize your game...



This overrides the default constructor - which adds all kinds of useful stuff such as a flycam and keybindings and such - so that the user is able to run some quick stuff virtually straight away.

When you get serious, this behavior will not be what you want - as you have discovered. And in that case, you would do what I’ve done above. Override the default behavior with your own custom behavior.

Still, you can code/debug many serious enough things with the flycam on - depending on where you start. And if you want to switch to some other cam on the run, you always can call something like ((Main)getApplication()).getFlyByCamera().setEnabled(false); Camera cam2 = ((Main)getApplication()).getCamera(); //…some setup…
and enjoy the view from the Node you attached it to…

Yeah, but depending on when you do that, FlyCamera might still register its listeners with the InputManager and screw you up. It’s not a very well written camera and was done before app states. So there is some funkiness with how it cleans itself up. Also when enabling/disabling the mouse cursor there is often an event ordering problem.

When you don’t want to use it, it is best to just not include it in the first place. Either by being specific about what app states you include (generally life is easier this way) or detaching it in simpleInitApp().