If a trigger or collision occurs on a collider, what Monobehaviors receive the OnTriggerEnter or OnCollisionEnter signals? Is it only those attached to the same GameObject as the collider, or all children, or all GameObjects above it as well? To help explain, here’s my hierarchy. Which object would get the signal?
A (parent object where script is attached)
B (object with collider)
(not obvious from above, but B, C, and D are children of A)
Would only object B get the signal? Or would A, B, C, and D get it? I ask because I have a script on object A where I want to know if the tigger/collision occurs, but it’s never getting called.
I think I figured out my problem. As whydoidoit led me to realize, I didn’t have a rigidbody on my GameObject anywhere. Adding a rigidbody got it to work, but only when the script was attached to the object that had the collider (in this case, B).
I guess what I really want is a method that I can pass a collider to and say “give me back all of the colliders that this intersects”. Because maybe I’m just a n00b (which I am), but I am constantly having issues getting colliders to work properly, and I see a lot of other people online having the same issues. It just seems silly that you have to have a rigidbody component to get triggers to work. In my mind, a trigger is a way to say “something passed through this thing”. What does that have to do with a rigidbody?