- Home /
How do I detect which collider is being collided with?
Hi, so originally I had one 2D box collider and was attempting to detect when a specific side of the collider is being touched, but I read that the easiest way to do it was to user four separate colliders on the object instead. I should mention that the colliders overlap a little, which I'm okay with, but for anyone who offers a solution, that detail might be important to know.
What I'm trying to do is detect when a specific collider is hit so that a different sprite animation plays depending on which collider is being touched. There's multiple box objects with four rectangular 2D colliders each that cover the top, bottom, left, and right side of the box object, and if the player is either on top of it, bumps their head below the box, or slides on the left or right side of the box, a different player animation plays for each one (and a different player action as well).
So the question is: how do I reference a specific collider out of the four colliders an object has, and how do I have the player object be aware of these differences? Thank you!
Your answer
Follow this Question
Related Questions
Weird ContactPoint2D on two BoxCollider2D collision 0 Answers
OnCollisionEnter is not working for me!! 1 Answer
Jump through a Collider 3 Answers
How to set collision for an object with specific collider size? 3 Answers
Collision detection problem 0 Answers