Unity2D disable player collision with ennemy when taking damage

264 views Asked by At

My player has multiple hearts, and i want to damage him one heart for every collision with an ennemy, but after each collision i want him to be invulnerable for a certain amout of time, and making him able to pass through the ennemy, thought about disabling his BoxCollider2D for a moment but that makes him fall through the ground as i'm using a Rigibody2D, how can i achieve that ?

1

There are 1 answers

0
Fatih Aslan On

There is two ways to do this:

1-https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html

2-https://docs.unity3d.com/Manual/LayerBasedCollision.html (You will change layers for a short period of time)