If a rigidbody collides with two or more colliders on the same frame, are the OnCollisionEnter() and other similar functions called once per object that has been collided with?
Say with the code below, if the gameObject the script is attached to collides with another with the tag PowerUp and another with the tag Enemy on the same frame and both checks are chained in an “if else statement” fashion, would this code execute correctly for both collisions on the same frame?
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("PowerUp")){
bounceEnemies = true;
} else if (other.gameObject.CompareTag("Enemy")){
BounceEnemy(other.gameObject);
}
}