Mouse events not working in mouse captured mode (3D)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PugMasterPug

I am making a First Person game, and I want to make it so that I can detect when the player’s mouse is over an object, I have a piece of code that looks like this:

func _ready():
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

The object I want to register mouse input has an Area node, and I use the mouse_entered() signal to register when the mouse is over, but it doesn’t work.

I also tried taking the Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) out of the code, and then it worked correctly.

:bust_in_silhouette: Reply From: fifnmar

This is a known issue and you can track it here. So far, we can set up a ray cast manually for that.

Can you explain what it mean out of the code, where I should put this code to make it work?

If you’re talking about the code in the first post, func _ready means that it is called after the node enters the tree and after all its children are ready, so basically at the start. Since input singleton is accessible from anywhere, you can put the code anywhere and it will work.