private void SetVerticalVelocity(float deltaTime) { if (GroundChecker.IsGrounded()) { verticalVelocity = Gravity; } else { verticalVelocity += Gravity * deltaTime; } }
private void Update() { if (!allowInput.RuntimeValue) { return; } bool isGrounded = groundChecker.IsGrounded(); if (isGrounded) { jumpCount = 0; } if (isGrounded || (jumpCount < maxJumps)) { if (Input.GetButtonDown("Jump") && !willJump) { willJump = true; } } }
void CheckMove() { // Check jump if (_groundChecker.IsGrounded() && _jumpHandler.CheckJump()) { _jumpHandler.Jump(_currentRobot.jumpVelocity, _currentRobot.positiveVelocityYBound); } // Triggers for animation if (_move != 0) { animationRenderer.SetTrigger("RobotRun"); } else { animationRenderer.SetTrigger("RobotIdle"); } Vector2 velocityVector = new Vector2(_move * _currentRobot.maxSpeed, _rigidbody.velocity.y); _rigidbody.velocity = velocityVector; _flipChecker.CheckFlip(_move); }