My code occasionally doesnt get past the if statement at line 3:
if (GroundCheck ())
{
if (velocity.y <= 0)
{
if (isJumping)
{
velocity.y = jumpForce;
}
else
{
velocity.y = 0;
}
}
}
I debugged it and got a lot of weird numbers, one was something like 2.05236E-05 or something similar
how can I deal with this?
RLin
3
Simply change the 0 to a relatively small float value, for example 0.01f.
mutoo
2
have you tried the Mathf.Approximately()
if (Vy < 0 || Mathf.Approximately(Vy, 0))
{
// do sth here.
}