I am shooting a bullet at my characters and they have head and body parts. I want to do damage to the player as a whole and not to the individual body parts. I am currently using this script to get the id of the object I’ve collided with how can I do something similar to get the name of the parent of this object?
private void OnCollisionEnter(Collision collision)
{
//checks if the thing hit was a player or something else
if (collision.gameObject.tag == "Player")
{
//gets the body part hit
hitID = collision.collider.gameObject.name;
//part that i need help with vvvv
playerID = collision.collider.gameObject.name;
//calls the damage player method
CmdPlayerHit(hitID, playerID, damage);
//Destroys the projectile when it hits a player
Destroy(this.gameObject);
}
else
{
Destroy(this.gameObject);
}
}