I tried but i didn’t got.
if you collide with two things at once yeah.
Are you meaning you want to get all the colliders involved in a collision?
No, i want to declare two kinds of colliders in the CollisionEnter
e.g. add a collison tag “”, and another collision tag in the same void
The function only takes one parameter and there are no overloads. The hits will come within miliseconds of each other, so it doesn’t matter. You just test for two different tags in the body.
if(CompareTag(“Player”) doSomething();
if(CompareTag(“Enemy”)doEnemySomething();
That’s not real code, you would need to find the gameObject from the collider first and get the tag, etc.
I’ve used something like
function OnTriggerEnter(object : Collider) {
if (object.tag == "myobject1" || object.tag == "myobject2" || object.tag == "myobject3) {
//dostuff..
}
}
What if i want diferente instructions for each If collision?
Then you’d just do something like…
function OnTriggerEnter(object : Collider)
if (object.tag == "myobject1"){
//dostuff..
}
else if (object.tag == "myobject2") {
//dootherstuff..
}
}
This Works in OnTrigger. Thanks!