Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        isGrounded = groundSensor.GetIsTouchingGround();

        var isJumping = animator.GetBool("isJumping");
        var isDocking = animator.GetBool("isDocking");

        if (isGrounded && isJumping)
        {
            animator.SetBool("isJumping", false);
            speed = defaultSpeed;
        }


        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        velocity.y += gravity * Time.deltaTime;
        if (controller.enabled)
        {
            controller.Move(velocity * Time.deltaTime);
        }

        if (isRunning)
        {
            Move(1.0f);
        }


        if (isGrounded && !isJumping)
        {
            if (Input.GetButtonDown("Jump"))
            {
                health.isInvincible = false;
                animator.SetBool("isDocking", false);
                animator.SetBool("isJumping", true);
                groundSensor.resetAllStatus();

                Jump();
            }

            if (Input.GetButtonDown("Fire3") && !isDocking)
            {
                StartCoroutine(Dock());
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (usePhysics)
        {
            isGrounded = groundSensor.GetIsTouchingGround();

            if (isGrounded && velocity.y < 0)
            {
                velocity.y = -2f;
            }
        }

        velocity.y += gravity * Time.deltaTime;
        if (controller.enabled)
        {
            controller.Move(velocity * Time.deltaTime);
        }
    }