Detecting collision on an object and not its sister object.

Forgive me if this isn’t really the proper way to describe this, but I’ll try to clarify.

I have a parent GameObject that I’ll refer to as the “capsule” object. It has two child GameObjects that each have their own Rigidbody and their own Trigger Box Collider. One child object has a script on it (it is the player script that handles movement and other player functions) and the other child object (referring to its sister in the title) is essentially a front bumper that extrudes out in front of the player object. When I call OnTriggerEnter in the player script it gets the Box Collider on the bumper object, which isn’t what I want in this case. Is there a way to make sure OnTriggerEnter isn’t firing off when its sister object is the one getting collision or should I be using a different function for this purpose?

Structure:
121218-structure.png

Player:

The bumper just has 3 components: Transform, Box Collider (trigger enabled), and Rigidbody.

Collider code on the player script:

void OnTriggerEnter(Collider other) {
		//If a player walks into the powerup, grant the player the powerup
		if (other.gameObject.tag == "Powerup") {
//etc
}
}

Hi there! Sounds like you want to use collision layers. In the Physics window you can see which collision layers interact with each other in a handy matrix. First you’ll want to create two new layers, Bumper and Player (for example) and set the layer of the Bumper and Player objects accordingly. Then in the collision matrix in the Physics window, uncheck the box where the Bumper and Player row/column intersects. Now when you hit play, you’ll find that OnTriggerEnter is no longer called, as the Physics engine is ignoring collisions between these two layers! Let me know if this helps at all :slight_smile: