Mouse input passing through CharacterBody2D

Godot Version

v4.3.stable.official [77dcf97d8]

Question

I have a CharacterBody2D on top of an TextureRect as my world background, both are programmed to do independent stuff when clicked.

The problem is when i click the character, the mouse input also affects the TextureRect behind. How can i ‘filter’ the input to avoid this?

Mouse filter in inspector. Here is someone’s tutorial.

https://www.reddit.com/r/godot/comments/wnisqw/i_made_a_short_text_tutorial_about_mouse_filter/

1 Like

But CharacterBody2D doesn’t have a mouse filter property, only control nodes have. Is it possible to make something like a mouse filter for a CharacterBody2D? i don’t want the input to pass through it.

Can you provide a screenshot of the scene structure, it could be a mouse signal being send to the player’s code.

1 Like

Alright, i managed to do a workaround by adding a invisible Panel node behind my player’s CollisionShape and set its mouse filter to ‘Stop’ so it works as i intended. Not sure if there’s a better way to do it.

Anyway, thanks yall for trying to help me!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.