Ejemplo n.º 1
0
    void Update()
    {
        if (onGround)
        {
            PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, NO_VELOCITY);
            PlayerUtility.ChangeAnimation(animator, RUNNING_ANIMATION);
        }

        // if (this.gameObject.transform.position.x >= FINISH_LOCATION_X_AXIS) {
        //     PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY);
        //     PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION);
        // }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (onGround)
        {
            PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, NO_VELOCITY);
            PlayerUtility.ChangeAnimation(animator, RUNNING_ANIMATION);
        }

        if (PlayerUtility.CanJump(onGround, Input.GetKey(SPACE)))
        {
            PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, JUMPING_VELOCITY);
            body2D.AddForce((Vector2.right * RUNNING_VELOCITY) * THRUST);
        }

        if (player.transform.position.x >= FINISH_LOCATION_X_AXIS)
        {
            PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY);
            PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION);
            txt.text = LEVEL_COMPLETE_MESSAGE;
        }
    }
Ejemplo n.º 3
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     onGround = false;
     PlayerUtility.ChangeAnimation(animator, JUMPING_ANIMATION);
 }