Compound Collider / Trigger problem

I’m relatively new to Unity so forgive me if I’m asking a stupid question.

Basically, I have an aeroplane (with attached rigidbody) and 3 primitive colliders parented to it. I am told the if multiple primitive colliders are parented to a single object with a rigidbody, they act as a single, compound collider.

The aeroplane flies through a single, isolated primitive collider (active as a trigger) and no rigidbody attached. The OnTriggerExit function is activated and the player is supposed to get one point. Instead it adds 3 points. I was under the impression that a compound collider acted as a single collider. Have I set this up correctly or am I just wrong?

If I’m wrong, can anyone think of a solution?
this is hurting my brain.

thanks in advance

Each collider will be detected. There are quite a few ways you can use to go around this. For example, you could tag one of the colliders gameObject and add code in the OnTriggerExit to add points only if the collider’s tag matches.

thanks for the reply. very much appreciated.

That’s the route I’ve been working on. Unfortunately my 3 or 4 days of coding experience aren’t quite up to it.

var score : int = 0
function OnTriggerExit (other : Collider) {
score += 1;
print(score);
}
}

That’s the code I have. I have been able to specify what the ‘other’ object is, but I don’t know how to specify what the Collider is. In theory i want something like the following (or using tags like you suggested which i also don’t know how to do):

var score : int = 0;
var specificCollider : GameObject;

function OnTriggerExit (other : Collider) {
if(Collider == specificCollider) {
score += 1;
print(score);
}
}

but I don’t actually know how to do it properly. i wouldn’t normally be annoying the internet like this but it’s part of a university assignment due in a couple of days.

Try this:

var score : int = 0;
var specificCollider : GameObject;

function OnTriggerExit (other : Collider) {
  if(other.gameObject == specificCollider) {
    score += 1;
    print(score);
  }
}

To get the tag of the collider : other.tag

To get the tag of a gameObject : GameObject.tag

To assign a tag during play : GameObject.tag = “tag” (String)

To assign a tag before play : Select a Game Object. Right before the Transform component, are the Tag and Layer field. Click on Tag, Add Tag. Click on Tags, define a size (depending on how many tags you need), insert the wanted tags. Return to your game object, give it the right tag.

Thanks very much for your help (both illogikaStudios and AkilaeTribe) but I think the problem is that “other” refers to the single collider that the three aircraft colliders are hitting. I need a way of accessing one of the aircraft’s three colliders. If I’m wrong about that then I’m not skilled enough to code it and I’m being too ambitious for my first project. Here’s the tag code I tried too if you’re interested:

var score : int = 0; 
var specificCollider : GameObject; 

function OnTriggerExit (other : Collider) { 
  if(other.tag == specificCollider.tag) { 
    score += 1; 
    print(score); 
  } 
}

I’ll just leave the score as +=3 for the moment.

You are perfectly right.

That’s why you must put the script on the other object, not on one of the three colliders. :wink: OnTrigger functions are triggered on both game object.

Haha thank you! I will have to redesign how the ring system will work but I suppose it’s much better than being terribly frustrated for hours.