I assume your question is : " How can I make sure that an event will only be triggered through a certain GameObject?"
public string tagToCompare = “Player”;
void OnTriggerEnter( Collider col ) {
if( col.transform.tag == tagToCompare){
DoSomething…
}
}
instead of (col.transform.tag…) you could also use if(col.transform.CompareTag(tagToCompare))
the second solution will be true if the collider object has the specified tag.
Make sure to give your “object” a collider and a tag. Further set tagToCompare equal to the object’s tag.
This solution hopefully works for C# .
However, here is the link to the API :
I hope I could help,
best wishes .
Daniel