public void OnStateUpdate() { if (!playerController.IsOnGround()) { playerController.PlayerState = PlayerState.Falling; return; } if (FocusController.Instance.Focusable != Focusable.Game) { playerController.PlayerState = PlayerState.Idle; return; } var jumpKey = playerController.Config.JumpKey; if (Input.GetKeyDown(jumpKey)) { playerController.PlayerState = PlayerState.Jumping; return; } var horizontal = Input.GetAxisRaw("Horizontal"); if (Mathf.Abs(horizontal) == 0) { playerController.PlayerState = PlayerState.Idle; return; } direction = horizontal; playerController.Direction = direction < 0 ? Directions.Left : Directions.Right; }
public void OnStateUpdate() { if (!playerController.IsOnGround()) { playerController.PlayerState = PlayerState.Falling; return; } if (FocusController.Instance.Focusable == Focusable.Game) { var jumpKey = playerController.Config.JumpKey; if (Input.GetKeyDown(jumpKey)) { playerController.PlayerState = PlayerState.Jumping; return; } var horizontal = Input.GetAxisRaw("Horizontal"); if (Mathf.Abs(horizontal) > 0) { playerController.PlayerState = PlayerState.Moving; return; } } if (playerController.Rigidbody.velocity != Vector2.zero) { playerController.Rigidbody.velocity = Vector2.zero; } }
public void OnStateUpdate() { if (playerController.IsOnGround()) { playerController.PlayerState = PlayerState.Idle; } }
public void OnStateUpdate() { if (playerController.IsOnGround() && !isOnGround) { return; } if (playerController.IsOnGround()) { playerController.PlayerState = PlayerState.Idle; return; } if (!isOnGround) { isOnGround = true; } }