# How to calculate IsGrounded more effective?

    if (SimpleInput.GetButtonDown(jumpButton) && IsGrounded())
{
}

bool IsGrounded()
{
return Physics.CheckCapsule(Char_Collider.bounds.center, new Vector3(Char_Collider.bounds.center.x, Char_Collider.bounds.min.y, Char_Collider.bounds.center.z), Char_Collider.radius * 0.27f, GroundLayers);
}


I've multiplied Char_Collider.radius with 0.27f 'cause in the tutorial that guy said You need to multiply this with %90 of your character's actual size That might be the problem because i don't actually know my character's size, i've made it in blender and scaled it down at the unity.

So if you look at the inspector panel you'll see it's 0.1 0.1 0.1 but it's actually not. I tried to spawn a cube and match them together roughly, cube's size was 0.3 1.2 0.3, that's way the number is 0.27f 'cause i just simply calculated it with the 0.3.

And finally my problem is:

I get return values from IsGrounded delayed, sometimes doesn't even get a value. Like example when i jump, sometimes it returns the value of IsGrounded False when i'm just about the hit the ground, and sometimes it doesn't returns the value of IsGrounded False. Because of this i can't make jump animation properly.

This is my HandleAnimation() method (I call that from FixedUpdate()):

void HandleAnimation()
{
if (!IsGrounded())
{
anim.SetBool("Jumping", true);
}
else
{
anim.SetBool("Jumping", false);
}
}


And this is my animator:

I am also adding those because sometimes when IsGrounded() returns false, animation doesn't works.

• We have gobs of existing Q&A about performing ground checks. Can you show us how you've tried implementing the solutions from these existing questions? I'm betting at least one of them will work for you, and if not, we can troubleshoot the particular issue you're having with it. – DMGregory Jun 10 '19 at 11:04
• I've red all of the stuff that is related to mine. But those are not helping. Btw I've edited my question with new stuff you should check it. – AmonRa's Channel Jun 10 '19 at 13:05
• In what specific way is it not helping? Without showing us how you've tried to apply this advice (like raycasts or spherecasts) and what went wrong, we're liable to just repeat the same kinds of tips that you've already deemed unhelpful. Help us understand what's so different about your case that the hundreds of tutorials that worked for other developers don't work for you, then we can try to fix that specific issue. – DMGregory Jun 10 '19 at 13:09
• Raycasts are working fine i don't think that's the problem but it might be about the IsGrounded(). I'm just not feeling it's the right way to calculate because it has delay, i think it doesn't calculate it everyframe but maybe 30fps don't have any idea. The thing that's not working for me is animation, it's not applied when jumping but it does sometimes, it's simply RNG. I'm thinking maybe it's because of my animator or the HandleAnimation() code. I'm still researching here and the youtube for that animation problem, but there is nothing so far. – AmonRa's Channel Jun 10 '19 at 13:48

So this IsGrounded() method is fine you can try it if this is your problem. Just make sure when multiplying Char_Collider.radius with 0.27f, You need to multiply it with your character's Actual Size not the Collider's Size.