My player has a shield which is parented to his hand, whenever something hits the shield it blocks it as expected but since it’s a child of the hand which is a child of the player, the player’s trigger function fires and takes damage.
Is there a way I can either avoid this altogether or detect if a collision came from one of the children of the player?
Try using Ignore Collision layer. Put your player object on it’s own layer, then the child hands/shield on their own layer (“Layer” drop down box is next to “Tag” drop down in unity inspector).
You can just use the number assignments as shown in the drop down for this function…
Here’s example code
{
Physics2D.IgnoreLayerCollision(3, 7, true); // IgnoreLayerCollision requires three fields (first layer to ignore, second layer to ignore, and true/false).
}
That is the 2D version of IgnoreLayerCollision. I believe the 3D version if just Physics.IgnoreLayerCollision