For some reason or another the second ‘else’ in this void is throwing out an exception. None of the normal things that would cause this seem to be present (no semicolons on the end of an if statement for example) so I am unsure what the problem could be. I have tried restructuring the void a bit, but nothing seems to alleviate the issue. Any help would be deeply appreciated.
void stateInAir(){
HandleHorizontalInput();
if (canJump) {
CanDoubleJump = true;
if (inputHoldTime < maxJumpButtonHoldTime && Input.GetKey (KeyCode.Space)) {
inputHoldTime += Time.deltaTime;
GetComponent<Rigidbody2D> ().velocity += new Vector2 (0, thePlayer.JumpAccel ());
} else {
if (Input.GetKeyDown (KeyCode.Space) && CanDoubleJump == true) {
setState (PlayerStates.ENTER_JUMP);
CanDoubleJump = false;
canJump = false;
}
}
else {
checkForGround ();
if (onGround) {
HandleLandOnGround ();
}
}
}
}