I want to make my character jump by a set amount instead of by a velocity. The way it is now, the double jump when activated at the beginning of the first jump sends the character flying really high, but if used at the bottom of the first jump, does almost nothing at all. I want to make them jump by set amounts instead so that they jump the same way no matter when or where the jump takes place.
Here is all the code related to jumping that I have. What could I do to fix this? Thanks.
//Ground Check Variables
bool onGround = false;
public Transform checkGround;
float groundRadius = 0.2f;
public LayerMask Ground;
public float jumpSpeed = 225; //Jump Speed
bool doubleJump = false;
bool tripleJump = false;
void Update ()
{
//Jump Control
if ((onGround || !doubleJump || !tripleJump) && Input.GetKeyDown (KeyCode.Space))
{
anim.SetBool ("Ground", false);
rigidbody2D.AddForce (new Vector2(0, jumpSpeed));
if(!doubleJump && !onGround && !tripleJump)
{
jumpSpeed = 200;
doubleJump = true;
}
if(doubleJump && !onGround && !tripleJump)
{
jumpSpeed = 100;
tripleJump = true;
}
jumpSpeed = 225; //Resets the first jumps' jumpSpeed.
}
}