I have an Empty GameObject with a script component. In the Empty GameObject are child GameObjects each with a Collider. I have a Player GameObject that fires shots. The Empty GameObject script has a OnTriggerEnter, is it possible to find what child GameObject Collider was hit?
Thanks.
OnTriggerEnter Will be called for every collider that hits your Trigger. From what I understand, you want to know which part of the player gets hit. To do so, simply put the script on each part of the player that you want to know is hit.
For exemple, if the player is a human, simply put the script on the head, body, arms and legs. If a bullet hit the player torso, the OnTriggerEnter function of the player’s body will be called.
If there is a way to do this with your current setup, I am not aware of it.
Hi,
Thank you for your reply.
I have a script on the parent game object that has the OnTriggerEnter. When I put a script on the body part (child of the GameObject with the first script) and added an OnTriggerEnter to it, the Debug.Log was never getting fired, it seemed like the parent’s OnTriggerEnter was overriding it. Does this sound right? or did I do something wrong?
Cheers.