How to only allow collision only on bottom side of 2d box collider Not top!

How to only allow collision only on bottom side of 2d box collider Not top!
I only want players sword to be able to react if it hits the bottom side of the enemies 2d box collider as you know when colliders are set when you touch top sides or bottom they trigger
–so I only want the bottom to collide etc with players sword.
so lets say if player swings sword on top of enemy 2d box collider , then it will not register , I only want to react if hits bottom of collider

2d game c#

2 Answers

2

you cant.

Unity’s collision system works by detecting whether an abject intersects an area(the colliders area) not its sides. what you are going to need to do is have multiple colliders on multiple game objects. Have the collider you want to receve damage when hit on an empty gameobject with a damage script attached to it.

You need to use the Platform Effector 2D as shown in this video:


Cheers.