I’m busy doing the Walker Boys 2D Mario clone tutorial, and I’m having an issue trying to get my gumbas to ignore each other. Each gumba is tagged as “enemy”, and each has 2 collision boxes (tagged as “enemyCollisionLeft” and “enemyCollisionRight”). I want the gumbas to react to collisions with the Mario character and various blocks, but to ignore each other. This is what I’ve tried:
Ted, OnCollisionEnter requires at least one of the objects to have a rigidbody, and the Collision parameter doesn’t have any info about what object is “providing” the collision.
I’ve tried using OnCollisionEnter (and thank you for that link, very helpful!) … it never gets called.
The problem, from what I’ve been able to tell, is that in my original code the IgnoreCollision only seems to work on the collision boxes themselves (which are set as triggers). It does not disable collisions for the CharcterController… and the gumbas therefore keep colliding. At least, thats what I think is happening. I can sidestep the issue by never allowing the gumbas to follow the same patrol paths, but this seems a silly way of fixing it.
As an aside… the objects are colliding just fine using isTrigger, I’ve used it successfully with all object interactions so far (pickups, damage, pathing etc etc). The only issue I’m having is when I don’t want the collision to happen. Is there something “wrong” with using triggers instead of OnCollision?
Another way to resolve if you don’t want to change the code, is to move down the “Box Collider” component below the “Character Controller” component (in the Gumba Object).
If you do this, it should work, at least for me it worked.