Hello!

I cannot make look by mouse work normally in Godot 4.2.1.

When mouse mode is set to anything other than MOUSE_MODE_CAPTURED, mouse pointer motion produces InputEventMouseMotion and I can use event.relative value. But eventually pointer leaves the window and InputEventMouseMotion stops coming.

But if I set mouse mode to be MOUSE_MODE_CAPTURED, mouse motion events are not generated and cursor stays in the center of the screen.

What would be the right way to make look by mouse in 3D in Godot 4.2.1 so that it doesn't leave the window and keeps producing motion events?

It must be the answer is trivial but for some reason I cannot figure it out. I'd appreciate any advice!

Thank you!

  • Toxe replied to this.

    z80 Works fine for me:

    func _input(event: InputEvent) -> void:
        var mouse_motion_event := event as InputEventMouseMotion
        if mouse_motion_event:
            print(mouse_motion_event.relative)
    (12, 0)
    (14, 0)
    (14, -5)
    (11, -8)
    (10, -8)

    How does your input code look like?

    • z80 replied to this.

      Toxe
      As soon as I set Input.mouse_mode = Input.MOUSE_MODE_CAPTURED, no motion events are generated at all. Please see the screenshots.

      • Toxe replied to this.

        z80 I'm not sure if you can set mouse mode while processing events. I would set it some time earlier, for example in your _ready() function or some other function that runs right after program start.

        • z80 replied to this.

          Toxe

          I moved " Input.mouse_mode = Input.MOUSE_MODE_CAPTURED" to _ready() and left only "print(e.relative)" in the _input(event) method. It produces no motion events at all. There are no print() statements in the output.

          Might it be due to I work via Windows RemoteDesktop rather than directly on a computer?

          I'll try to physically get to the computer and see if it behaves the same way.

          • Toxe replied to this.

            z80 I don't know but that might be a possibility.

            Another thing you could try is creating a new, empty project and just create a simple Node that has nothing more than a _ready() function to enable mouse mode and your input processing. I did kind of the same to test it on my side.