How do you detect clicks on a 2D (rigid) body?

Godot Version4

Question

Every tutorial I found says to use _input_event(viewport, event, shape_idx). But it never executes for some reason. I guess it is because my tree looks like this:

  • Control
    • RigidBody2D
      • CollisionShape2D

As said in docs, _input_event accepts only unhandled events, and Control handles event before RigidBody. But in Godot there is no ability to manage event handling order!
I could write own functions for detecting a click. It would be easy to do for simple shapes such as circle and square, but I don’t think it is the smoothest solution (even for simple shapes, but I have some much more complex shapes)
So, how do you detect clicks on a RigidBody?

Make sure it is “Input Pickable” in the properties/inspector

Yes, it is, there is still same issue

You can try setting the Control node to ignore or pass mouse inputs

1 Like

Well, now rigid body handles events, but it would be better to make Control keep ability to handle events
But at least rigidBody can handle events, thanks for responding quickly

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