Mouse velocity with MOUSE_MODE_CAPTURED

Godot Version

4.3

Question

Hi, for some reason both screen_velocity and velocity give me (0,0) when using them with Input.MOUSE_MODE_CAPTURED, can anyone tell me how to get them to work? note that screen_relative and relative do work

When you set your cursor to captured it is kept at the center of the screen. I think that is why it has no velocity.

InputEventMouseMotion — Godot Engine (stable) documentation in English then is this talking about something else? if so can you explain it to me?

try this:

func _input(event):
    if event is InputEventMouseMotion:
        print("mouse velocity: ", event.relative)

It is the common way to get mouse velocity while mouse is captured

Thanks for answering, though I already use this method

i was asking because because the documentation recommended i use screen_velocity with Input.MOUSE_MODE_CAPTURED but it kept giving me (0,0)

1 Like

Umm. I think so it should be Input.set_mouse_mode(MOUSE_MODE_CAPTURED)

Yes, im aware thats how to set it. The mode works fine for me aside from the velocityt hing, Input.MOUSE_MODE_CAPTURED is the name of the Constant