public void Update()
 {
     if (controller.JumpKeyPressed())
     {
         Jump();
     }
     if (controller.LeftKeyPressed())
     {
         Left();
     }
     else if (controller.RightKeyPressed())
     {
         Right();
     }
     else
     {
         horizontalMovement = 0;
     }
     if (controller.InteractKeyPressed())
     {
         Interact();
     }
     else
     {
         curentState = PlayerState.Normal;
     }
 }
Ejemplo n.º 2
0
    void Update()
    {
        directionalInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        if (directionalInput.x > 0 && !facingRight && curentState != PlayerState.Interacting)
        {
            Flip();
        }
        else if (directionalInput.x < 0 && facingRight && curentState != PlayerState.Interacting)
        {
            Flip();
        }
        player.SetDirectionalInput(directionalInput);
        animator.UpdateMovement(directionalInput.x != 0 ? true : false);
        animator.SetGrounded(player.IsGrounded());

        if (controller.JumpKeyPressed() && curentState != PlayerState.Interacting)
        {
            player.OnJumpInputDown();
            animator.TriggerJump();
        }
        if (controller.JumpKeyReleased() && curentState != PlayerState.Interacting)
        {
            player.OnJumpInputUp();
            animator.ResetJump();
        }
        animator.SetGrounded(player.IsGrounded());
        animator.SetFalling(player.isFalling() ? true : false);
        if (controller.InteractKeyPressed())
        {
            interactionHandler.Interact();
        }
        else
        {
            curentState = PlayerState.Normal;
        }
    }