2D platformer. How to make enemies pass through player.

Hello.
Basically I just started having fun with Unity. Came here from GameMaker Studio.
I’m experimenting with the “2D Platformer” example that Unity has on it’s asset store (the one used in tutorials with potato shooting at aliens). I manged to make his bazooka aim at mouse cursor and made the shooting more vertical and all.

Now I have another issue with how the example works. Mainly, the problem is when 2 enemies run into you from both sides, my hero gets lifted in the air and stuck between them, unable to jump because his feet don’t touch the ground. Also it’s really unintuitive for a platformer to have enemis act as solid platforms that can push you around and so on. Is there a way to make them pass through me like in Super Mario but still detect collision with ground and my player to hurt him?

Yeah that’s possible. The Rigidbody2D should be set to “Kinematic” and you can set the colliders to act like triggers. That way, OnTriggerEnter2D gets called where you can handle collision logic as usual.

If you want to keep using the 2D Physics you can keep the rigidbody as non-kinematic but have the collision component only collide with the environment, but not with the players. That way they can walk through each other. You would then add a child object with the trigger setup as above to catch enemy/player collisions.

How to exactly do THAT?

EDIT: Oh wait, I just found out Phisics2DSettings, I guess you ment that

Physics2DSettings refers to layers, and yes that is extremely simple way to make player not collide with enemies.