[SOLVED] Where to put inputManager.setCursorVisible(true);?



I’m currently working through the tutorials on the github, and am currently at Hello Picking. At some point, the tutorial explains how to point and click in a 3D model using your mouse. For this, they give a code, and tell you to also use inputManager.setCursorVisible(true). They also explain that it is now not possible to move the camera using the mouse.

Changing the code doesn’t give an error, but I cannot seem to find the code where I have to put inputManager.setCursorVisible(true). The only place where it works in is public void onAction, where the mouse becomes visible after clicking once. Even when using this code, the camera still moves by moving the mouse, however.

Where do I have to put this line of code, and do I have to manually disable the camera moving by the mouse?

Here the code that I changed it into:

// 1. Reset results list.
        CollisionResults results = new CollisionResults();
        Vector2f click2d = inputManager.getCursorPosition().clone();
        Vector3f click3d = cam.getWorldCoordinates(
            click2d, 0f).clone();
        Vector3f dir = cam.getWorldCoordinates(
           click2d, 1f).subtractLocal(click3d).normalizeLocal();
        Ray ray = new Ray(click3d, dir);
        shootables.collideWith(ray, results);
        // 4. Print the results

Thanks in advance!


Well, that’s because you didn’t disable the flyCam. The flyByCamera control enables/disables the cusror visibility in different circumstances, you should see the code if you want to know exactly when.

If you want just to have the cursor and not the flyCam controls, just disable it. You have several ways:

EDIT: To put blocks of code, you should use: ``` before and after the code ```


This fixes everything! I didn’t understand from the text that I had to manually disable to flycam. Thank you very much!

And thank you for the tip about blocks of code :slight_smile: