void Update() { bool inputJump = Input.GetButton("Jump"); bool Grounded; if ((Time.time - lastGroundedTime) < CoyoteTime) { Grounded = true; } else { Grounded = CheckForGround(); if (Grounded) { lastGroundedTime = Time.time; } } playerRigidbody.velocity = MathW.SetVector(playerRigidbody.velocity, 1, playerRigidbody.velocity.y + (Time.deltaTime * Gravity * -1f)); if (inputJump && Grounded) { Jump(); lastGroundedTime = 0; } }
// Update is called once per frame void Update() { playerRigidbody.velocity = MathW.SetVector(playerRigidbody.velocity, 1, playerRigidbody.velocity.y + (Time.deltaTime * Gravity * -1f)); if (Input.GetKeyDown("space")) { Jump(); } }
void Jump() { playerRigidbody.velocity = MathW.SetVector(playerRigidbody.velocity, 1, JumpHeight / JumpTime); }