Box cast issue
Hi everyone, I try to check if my character is grounded with a boxCast. The character's collider is a boxCollider. But m_IsGrounded is desperately false... It's true only for like 6 frames when my character is falling on the ground, and then, when my character have landed, it is false again. If I increase maxDistance, it's true for like 100 frames but then it's false again. If i remove maxDistance, it's always true, even when my character is not grounded, except on plane, it's always false. What i am doing wrong?? This function is call in update() of my character controller.
public void CheckGroundStatus()
{
float maxDistance = 0.2f;
if(Physics.BoxCast(transform.TransformPoint(m_BoxCollider.center), m_BoxCollider.size * 0.5f, Vector3.down, out hitInfo, transform.rotation, maxDistance)) {
Debug.LogWarning("Is Grounded");
m_IsGrounded = true;
}
else
{
m_IsGrounded = false;
}
}
I debug it with DebugBoxCollider.DrawBox(transform.TransformPoint(m_Box.center), m_Box.size * 0.5f, transform.rotation, Color.blue);
and it print exactly what i expect. Thank you
Your answer
Follow this Question
Related Questions
How can I implement box collider or mesh collider in this code? 0 Answers
Character doesn't collide with the floor. 0 Answers
Enemy bullets pass through my walls 0 Answers
How To create 2D collision detection on object which changes dimensions 1 Answer
2D Collisions Not Working,2d Collision not working? 0 Answers