#Why Jump and Quick dash dont work ?

1 messages · Page 1 of 1 (latest)

main hollowBOT
rapid moss
#

private void MyInput()
{
//Input
horizontalInput = Input.GetAxis("Horizontal");
verticalInput = Input.GetAxis("Vertical");

    //Direction
    moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;

    //Jump
    if (Input.GetKey(jumpKey) && grounded && readyToJump)
    {
        Jump();

        readyToJump = false;

        Invoke(nameof(ResetJump), jumpCooldown);
    }
    //Quickdash
    if (Input.GetKey(quickdashKey) && readyToQuickdash)
    {
        Quickdash();

        readyToQuickdash = false;

        Invoke(nameof(ResetQuickdash), quickdashCooldown);
    }
}
#

private void Jump()
{ //reset y velocity
rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);

    rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
}
private void ResetJump()
{
    readyToJump = true;
}
private void Quickdash()
{
    rb.linearVelocity = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);

    rb.AddForce(transform.forward * quickdashspeed, ForceMode.Impulse);
}   
private void ResetQuickdash()
{
    readyToQuickdash = true;
}

}