// Update is called once per frame void Update() { UpdateState(); switch (currentState) { case State.Fleeing: seekComponent.flee = true; seekComponent.SetTargeter(playerTargeter); movement.speed = fleeSpeed; break; case State.SeekFood: seekComponent.flee = false; seekComponent.SetTargeter(appleTreeTargeter); movement.speed = appleTreeSpeed; break; case State.Eating: timeEating += Time.deltaTime; if (timeEating >= maxEatTime) { doneEating = true; ((AppleTreeTargeter)appleTreeTargeter).UpdateTree(); } break; } }