How to prevent a game object from colliding with its parent

I am trying to implement interchangeable weapons, each with there own collision behavior via triggers. The problem is the weapons seem to be triggered by the parent game object holding them. Is there a way to determine if two objects are of the same tree? I have tried the following:

`
void OnTriggerEnter (Collider otherObject)
{

// Playsound, show effect

	Debug.Log("Melee - OnTriggerEnter");
	
	Character targetCharacter = (Character) otherObject.GetComponent("Character");
	Character myCharacter = (Character) gameObject.GetComponent("Character");
	
	
	if(!targetCharacter.Equals(myCharacter)){
		targetCharacter.Hurt(damage);
	}
}

`

There are no complaints about “myCharacter” being null.

I have also tried getting the parent object via gameObjects’s transform but no luck. Further more I tried iteratively getting the parent’s parent etc. (being that the weapon is part of the hand of the rig) until null is returned but that just causes my script to spin.

You are going to want to use Physics.IgnoreCollision,

here’s a link:
Ignore Collisions

Thanks Syntinel. That function makes my code a bit more elegant. For reference, I was able to specify the parent collider using transform.root.