Finding name of collider hit from a parent object

I’ve set up an enemy where each individual game object is linked together with joints. (essentially a partial ragdoll) I’m launching rigid body bullet objects in my game at the enemy, and on a collision, I want to figure out which part of the enemy the bullet hit. I want to do this from the parent object on the enemy, instead of having individual scripts on each body part. So how can I find the name of the child object that is being collided with, from an OnCollisionEnter call in the parent script?

Any help is greatly appreciated!

You can’t. Only the object getting hit gets notified, so you need scripts in the children to notify the parent. What I usually do is attach them during runtime. Something like this (I haven’t tested it, but it should more or less work)

public class Parent : MonoBehaviour
{
	private class ParentNotifier : MonoBehaviour
	{
		void OnCollisionEnter(Collision coll)
		{
			transform.parent.gameObject.SendMessage("OnCollisionEnter", coll);
		}
	}
	
	void Start()
	{
		foreach (Transform child in transform)
			child.gameObject.AddComponent<ParentNotifier>();
	}
	
	void OnCollisionEnter(Collision coll)
	{
		// process on collision here!
	}
}