개발일지/스파르타 코딩클럽 부트캠프

[TIL] 7주차 3일 개인과제주차

치치베베 2024. 5. 29. 21:05

 

오늘 발생한 문제


value값이 null이 되는 문제

 

public void OnUseButton()
{
    if(selectedItem.type == ItemType.Consumable)
    {
        for(int i = 0;  i<selectedItem.consumables.Length; i++)
        {
            switch(selectedItem.consumables[i].type)
            {
                case ConsumableType.Health:
                    condition.Heal(selectedItem.consumables[i].value);
                    break;
                case ConsumableType.Hunger:
                    condition.Eat(selectedItem.consumables[i].value);
                    break;
                case ConsumableType.Boost:
                    condition.Boost(selectedItem.consumables[i].value);
                    break;
            }
        }
        RemoveSelectedItem();
    }
}

여기서 Boost의 value값이 적용이 되지 않는데

이유를 모르겠다 인스펙터에서도 아이템데이터에서도 다 적용해줬는데 그냥 개빡침

 

public void Boost(float value)
{
    controller.moveSpeed += value;
    StartCoroutine(BoostTime(value, boostTime));
}

IEnumerator BoostTime(float value, float time)
{
    controller.moveSpeed -= value;
    yield return new WaitForSeconds(time);
}

Boost 함수가 시작하는 동시에 에러가 뜨는걸 보니 value에 null값이 들어가는듯 하다. 아직 해결못함