OnTriggerEnter for a collider attached to another gameObject

I need to check when an object enters a collider attached to another game object. I have set the collider through the inspector as a public variable. I tried using the standard onTriggerEnter function but passing the other collider in, however this doesn’t seam to work.

Is there a way to detect gameObjects entering colliders attached to other game objects?

public SphereCollider theCollider;

// Check if GameObject enters
void OnTriggerEnter (Collider theCollider) {
	//Do Stuff
}

Hi, I would have the OnTriggerEnter(or collision variant) function attached to the object that you want to detect the event on. When triggered call a function on the script/object you need this information for. Create a reference to the main script at the start of your collider scripts.

void OnTriggerEnter (Collider theCollider)
{
if(col.tag == “tagname”)
{
//do stuff
}
}

you need to set a tag name to the object you want to collide with your collider.
If you have allot of collisions i suggest using switch instead of if statements.