public static void ConsumeStamina(float consumption)
{
if(_currentPlayerST > 0)
{
_currentPlayerST -= consumption;
_currentPlayerST = Mathf.Clamp(_currentPlayerST, 0, _playerMaxStamina);
}
}
public static void RecoveryStamina(float recoveryQuantity)
{
if (_currentPlayerST < _playerMaxStamina)
{
_currentPlayerST += recoveryQuantity;
_currentPlayerST = Mathf.Clamp(_currentPlayerST, 0, _playerMaxStamina);
}
}
clamp는 stamina를 float 값을 설정하였기 때문에 보정을 해주었다.
해당 동작이 들어갈 때 혹은 실행 중에 소모 및 회복을 구현하기 위해 state behaviour를 사용하였다.
하지만 예상치 못한 문제점이 발생했다.
stamina error
동작을 처음 실행할 때만 stamina가 소모되는 animation 에서 소모량 만큼 소모되고 일시적으로 회복이 되는 현상이 발생했다.
이는 animation transition 기간 안에 발생한 것으로 animation transition 값을 0으로 바꾸었을 때, 그 현상이 사라졌다.