Alright so I've got a jump function and for some reason it can be called more then once (causing superjumps). This happens more often on hills. Problem is my code shouldn't even let that happen so I have no idea how to fix it.
In function FixedUpdate (I'm gonna change it to update when I clean up my code) I have this:
if (!Stunned && Grounded && Input.GetButtonDown("Jump") && !IsJumping)
{
Jump ();
IsJumping = true;
}
Pretty self explanatory. The problem in my jump function is from these lines of code:
if (!Grounded)
{
LeftGround = true;
}
if (Grounded && LeftGround)
{
IsJumping = false;
//other code stopping the Jump function that's not important is here
}
That section of code is in a for loop using yield new WaitForFixedUpdate() at the end. I wanted the function to cancel when they land and doing it this way prevented the function from cancelling instantly.
So, any ideas as to what is causing the problem? I just can't see how it can be called twice due to IsJump so I'm clueless.
↧