I want to handle in a single object different Colliders (Triggers). If an object enters in one of the colliders, I need to know in which one. Is that possible ?
The way it works is that it’s the triggers that receive the messages.
So you need to forward the message to the object entering the triggers.
Something in the like :
// on the Trigger
void OnTriggerEnter (Collider other)
{
other.gameObject.SendMessage ("Entered", this.gameObject);
}
// on the entering object
void Entered (GameObject trigger)
{
// do what you need with the given object
}
Now, using SendMessage isn’t the best option performance wise, but it’s enough for prototyping.
You can also use component or interface
// on the Trigger
void OnTriggerEnter (Collider other)
{
other.GetComponent<Player>.Entered (this.gameObject);
}
// on the entering object
public void Entered (GameObject trigger)
{
// do what you need with the given object
}