I’d like all of my characters to not actually collide with each other, but still react to collisions with each other so I can call events.
I’m making a 2D game and it just causes problems when groups of enemies walk into each other and can’t go anywhere. If two characters walk into each other, I would want them to pass right though each other. The 2D demo game does this by putting the enemies on a separate layer and then setting the layer collision matrix so that that layer does not collide with itself.
The problem with that is that then the objects on that layer can’t call collision functions. If I needed an enemy to react to bumping into another enemy, I can’t use the OnCollision functions. If I want the player to pass through the enemy by making the player layer not collide with the enemy layer, then the enemies can’t call an OnCollision function when they touch the player.
If I make the collision channel just a trigger, then I won’t have collision with the ground and I’ll fall through the world.
You could try to put two colliders on the object. One you handle as you described the sample does so it doesn’t interact with other characters but interacts with ground and another on a child gameobject that is just a trigger.
I add an empty child to my characters called “Hitbox” and add a box collider to it, and set it to a Trigger. The Hitbox can be its own layer, and handle collisions with things like bullets, fireballs, or other players or their hitboxes. Meanwhile the parent retains the character controller to handle movement and collision with terrain, obstacles, etc.
Having the hitbox as a trigger allows you to pass through other players while still generating an OnTrigger events so that you can react to hitting an enemy. Just make sure you remember that the Trigger collider is the Hitbox, so you should act on collider.parent if you need to access the actual character.