Wanheda
Wanheda

Reputation: 71

How to ignore collisions but raise the trigger event in unity2D

I have an enemy collider 2D and player collider2D. I need player to be possible to go through enemy. I set Physics2D to

Physics2D.IgnoreLayerCollision(10 (Player layer), 12(Enemie layer));

But I still need event which shows that player interacted with enemy. I added trigger on enemy, but OnTriggerEnter2D() function isn't working

Upvotes: 0

Views: 238

Answers (1)

derHugo
derHugo

Reputation: 90580

Why would you ignore the layers?

You need them to "collide" with each other in order to have trigger events as well!

The Collision Matrix should rather be read as "Interaction Matrix" and IgnoreLayerCollision rather as "Ignore Layer Interaction".

You rather want to enable Collider2D.isTrrigger so objects can pass this collider but still receive trigger events as long as you fulfill the conditions listed in the Collision Action Matrix

Upvotes: 1

Related Questions