Solved how to get half the collider of a box2d or capsulecollider2D
private void OnCollisionStay2D(Collision2D collision)
{
if((collision.contacts[0].collider.bounds.center.y - (collision.contacts[0].collider.bounds.extents.y - collision.contacts[0].collider.bounds.max.y)) >
(collision.contacts[0].otherCollider.bounds.extents.y - collision.contacts[0].otherCollider.bounds.max.y))
{
}
//First part of the if statement is the detection of the bottom half of the gameobject's collider, after the ">" is the top part of the object that your gameobject is colliding with. This is being used for going up ledges , private void OnCollisionStay2D(Collision2D collision) { if((collision.contacts[0].collider.bounds.center.y - (collision.contacts[0].collider.bounds.extents.y - collision.contacts[0].collider.bounds.max.y)) > (collision.contacts[0].otherCollider.bounds.extents.y - collision.contacts[0].otherCollider.bounds.max.y)) { print("RECOGNIZED BOTTOM HALF COLLIDER AGAINST THE TOP OF A COLLIDER" + "yey"); } //first half is the gameobject's collider and after the ">" is the top of the other collider.
Your answer
Follow this Question
Related Questions
How to make a boat move without controling it ? 0 Answers
How to add animations to character ? 0 Answers
Objects destroy when collide with each other 0 Answers
Manual GUI Refresh 0 Answers