- Home /
Using multiple collidrers in OnTriggerEnter?
Hello, I wonder if it's possible to use multiple collidrers in a single OnTriggerEnter? for example:
void OnTriggerEnter (Collider other, Collider door, Collider start)
{
if (other.CompareTag("other")
{
//do something
}
else if (door.CompareTag("door")
{
//do something else
}
else if (start.CompareTag("start")
{
//...
}
I didn't get that to work for me but maybe there's a way to play it around? *please dismiss any typos here....
Comment
Best Answer
Answer by TonyLi · Jun 20, 2017 at 08:11 PM
OnTriggerEnter has one specific signature: OnTriggerEnter(Collider).
void OnTriggerEnter (Collider other)
{
if (other.CompareTag("other")
{
//do something
}
else if (other.CompareTag("door")
{
//do something else
}
else if (other.CompareTag("start")
{
//...
}
You can still put multiple colliders on a GameObject. If any of them are triggers, Unity will invoke OnTriggerEnter for each one.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
OnCollision and OnTrigger being called twice 3 Answers
What are these things doing in C#? 3 Answers
my enemy is broken 1 Answer