void Update() { UpdateNextState(); if (currentState == null) { return; } stateTime += Time.deltaTime; if (currentState.totalTime <= stateTime) { if (currentState.nextState != null) { SetNextState(currentState.nextState, true); UpdateNextState(); } else { currentState.End(); currentState = null; } } else { float progress = 1; if (currentState.totalTime > 0) { progress = stateTime / currentState.totalTime; } currentState.Update(progress); if (currentState.hitTime >= 0 && currentState.hitTime < currentState.totalTime - stateTime) { currentState.hitTime = -1; currentState.Hit(); } } }