You can also do this with just vanilla collider setup and physics layers.
Make two layers in your Tags and Layers settings:
- PlayerCollision — represents a solid player character
- PlayerTrigger — represents trigger-only interactions with player characters
In your physics settings, tick the boxes so that the PlayerCollision layer does not collide with PlayerTrigger. Both layers can still collide with themselves, with default, etc.
Give your player character prefab two child objects with colliders attached: one on the PlayerCollision layer, and one on the PlayerTrigger layer. Set
isTrigger to true on the second one.
Now, anything that should stop the player can go on the default layer — it will interact with the non-trigger PlayerCollision collider on the player character and halt it.
Anything that should not stop the player should go on the PlayerTrigger layer. It will interact with the player's trigger collider and send trigger messages, without triggering a physical collision resolution.
These entities can still physically interact with other entities on the default layer (if you don't want them colliding with anything, then just set the entity's own collider's
isTrigger to true instead)
This gives you the flexibility to make the player's trigger volume different than their collision volume, if that's useful for your needs. And it correctly filters all the physics behaviours without adding extra component types into the mix.