Assign OnTriggerEnter to a specific BoxCollider

Hello

I’m novate so my question is basic nevel.

I have a script with an OnTriggerEnter implemented within an object. I want that this function only is called when there is a trigger enter of this object.

The fact is that this function is called by everyobject of the scene when they have an trigger enter.

I’m using C#

Add some unique value to your object that contains a “specific BoxCollider”.

//For example it can be a tag, then:
void OnTriggerEnter(Collider colidedObj)
{
    if (colidedObj.tag == "UniqueTag")
    {
        //do your work
    }
}
//Or it can be a unique name, then:
void OnTriggerEnter(Collider colidedObj)
{
    if (colidedObj.name == "UniqueName")
    {
        //do your work
    }
}
//Or any other unique variable