- Home /
Question by
cheesewhiz999 · Dec 12, 2016 at 08:17 AM ·
collision.contacts
How to find contact point with lowest y position
void OnCollisionStay(Collision collision){
ContactPoint c=collision.contacts[0];
Vector3 colAngle = c.normal;
foreach(ContactPoint contact in collision.contacts){
if(contact.point.y<c.point.y){
c=contact;
colAngle=c.normal;
}
}
float slopeAngle=Vector3.Angle(colAngle, Vector3.up);
if(slopeAngle<=maxGroundAngle){
isGrounded=true;
}else{
isGrounded=false;
}
}
The issue I'm having is that my character cannot jump when next to a wall but still on the ground, so I'm trying to test the angle of the collision at the lowest contact point. How would I correctly find the contact point with the lowest y position?
Comment
Answer by Marceta · Dec 12, 2016 at 08:53 AM
You can check if object that has collided with player have tag "Ground" or "Floor" whatever you set to your ground objects. That is maybe easiest solution for you: http://answers.unity3d.com/questions/189000/collision-with-tag.html
If you want something "advanced" i would use raycast and do something like this guy:
http://answers.unity3d.com/questions/196381/how-do-i-check-if-my-rigidbody-player-is-grounded.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612102520im_/https://answers.unity.com/themes/thub/images/avi.jpg)