Ejemplo n.º 1
0
 private void SetVerticalVelocity(float deltaTime)
 {
     if (GroundChecker.IsGrounded())
     {
         verticalVelocity = Gravity;
     }
     else
     {
         verticalVelocity += Gravity * deltaTime;
     }
 }
Ejemplo n.º 2
0
    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;
            }
        }
    }
Ejemplo n.º 3
0
    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);
    }