• Godot Help
  • How to know which node triggered the signal?

Godot version 4.0.3
so i have been making a 3D ui and using 3D elements like mesh and Label3D. I was using the StaticBody3D signal "_on_static_body_3d_input_event" for one script due to optimization and flexibility reasons but i encountered a huge problem. When i click one of my three buttons using "event" (InputEventMouseButton) same signal triggered and all my buttons doing same things. So my question is how can i know which node triggered the signal so i can make buttons do different things. Here are some screenshots:


random color for op1 is for debugging dont mind that
thank you

My guess is that the shape_idx (shape index) parameter could be used to accomplish this. There are CollisionObject3D (ancestor of StaticBody3D) methods dealing with shape indices, shape IDs and shape owners.
https://docs.godotengine.org/en/4.0/classes/class_collisionobject3d.html#collisionobject3d

For example, shape_find_owner() gets the shape owner ID from the shape index, and shape_owner_get_owner() gets the parent object from the owner ID. I should think that would let you determine which button object was clicked.

To be more specific, I would have to set up a test project and experiment.

    Lebweuh shape_find_owner() is still in 4.0

    You are currently calling the method on self. Is that script attached to a CollisionShape?