Using a Single Collider to Detect Collisions with Multiple Colliders

I am currently working on making a script for picking up tools. My current design is attempting to use a collider in the parent object of the player to detect collisions with three different types of tools and change booleans accordingly.

function OnTriggerEnter (other : Collider){
    if(other.gameObject == pickaxe){
    	canPickupPickaxe = true;
    }
    else if(other.gameObject == flareGun){
    	canPickupFlareGun = true;
    }
    else if(other.gameObject == radMeter){
    	canPickupRadMeter = true;
    }
}

function OnTriggerExit (other : Collider){
    if(other.gameObject == pickaxe){
    	canPickupPickaxe = false;
    }
    else if(other.gameObject == flareGun){
    	canPickupFlareGun = false;
    }
    else if(other.gameObject == radMeter){
    	canPickupRadMeter = false;
    }
}

However, when the player object collider collides with the tool’s collider, the corresponding canPickup variable does not change. Is it possible to use a single collider to do this or have I made another mistake that is preventing this from working?

if(other.gameObject == pickaxe){

This comparison operation will only return true if the variable pickaxe references the exact same instance as the gameObject you have collided with. If pickaxe is the prefab, and the gameObject you collided with is an instance of that prefab, it will return false.

If the pickaxe has the tag pickaxe you should be checking.

if(other.gameObject.tag == "pickaxe")

or, if you’re doing it by name

if(other.gameObject.name == "pickaxe")

Notice in both of those examples I am comparing the strings for the name or tag with another string. Comparing strings with the == operator will do a value comparison and return true if the strings have the same value.

What your code is doing with the == is comparing two references, which will only refer true if they refer to the exact same instance.
That’s almost certainly not what you want to do.

try checking for the name of the game object for example:

instead of

if(other.gameObject == pickaxe)
{
canPickupPickaxe = true;
}

try:

 if(other.name == pickaxe)
{
canPickupPickaxe = true;
}

because its already checking for the collider, just have it check for the name of the game object that the collider is attached to.

I managed to solve my own issue for this problem. I was using two different trigger colliders on the player object and the interaction between them was preventing my script from working properly. Thank you for the suggestions about referencing objects with triggers however.