I can't manage the mouse when I set the cursorVisible false

Hello, I have this problem, I need to change the mouse cursor position when it is invisible, but if I set
inputManager.setCursorVisible(false) then I can’t manage the mouse though the org.lwjgl.input.Mouse anymore.

I’m trying to replicate this Dead Space - Perfect Asteroid Run - YouTube, I need to change the mouse position when it goes out the window’s border to put it back inside the border.

this is my update code

obbiettivo is the Vector obtained from the intersection between the Ray that start from the mouse and the wall used as the start point for the meteorites

arrow is used as the cannon’s laser

thank you for your help and sorry If I made any English mistake

public void update(float tpf) {
    super.update(tpf); //To change body of generated methods, choose Tools | Templates.
    CollisionResults results = new CollisionResults();
    Ray ray = new Ray(new Vector3f(0,inputManager.getCursorPosition().getY()-(settings.getHeight()/2), inputManager.getCursorPosition().getX()-(settings.getWidth()/2)), new Vector3f(600, 0, 0));

    rootNode.collideWith(ray, results);
        obbiettivo = results.getClosestCollision().getContactPoint();
    cannonNode.lookAt(obbiettivo, Vector3f.UNIT_Y);
    if(inputManager.getCursorPosition().getX() <= 190){

    if(inputManager.getCursorPosition().getX() >= 1089){
    if(inputManager.getCursorPosition().getY() >= 615){
    if(inputManager.getCursorPosition().getY() <= 207){

You can maintain full control of the mouse when masking the mouse cursor with a fully transparent image. You’d need to disable all mouse button event listeners though.

1 Like