Hero, Enemy, MapDeco(ration, static) object. All has its own rigidbody2d, collider2d.
[Game should be, ]
*Hero can pass through Enemy, but not MapDeco collider.
*Enemy can’t pass through each other and MapDeco.
*When Hero pass through, or stay on Enemy, should be damaged by enemy, so there need to be some recognition mechanism.
[What I tried]
I made hero’s collider’s [IsTrigger] on. But then hero pass through all objects.
→ Should not pass through MapDeco. So failed.
I made hero’s collider’s [IsTrigger] off. And add Enemy layer to Exclude layer at Rigidbody or Collider.
→ Can’t recognize enemy collide or stay with Hero, can’t damage, so failed.
You’re probably going to need more than three layers as well, alongside making some objects siblings rather than children of other objects so they don’t inherit their collision properties. Eg, trigger objects that are coded to follow enemies around (rather than a child object of them), so players can ignore enemy’s collision, but still trigger events on the trigger objects.
Thanks. It is brilliant way. I made child object at Enemy and made same renderer, rigidbody, collider and make it IsTrigger On.
Only difference with parent Enemy is Layer.
So now Hero pass through Enemy but triggered by enemy children’s trigger.