Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        // Update current state
        currentState.UpdateState();

        // Detect state change and call StartState method in current state
        if (previousState != null && previousState != currentState)
        {
            Debug.Log("State changed! " + previousState + " -> " + currentState);

            // Activate start state
            currentState.StartState();
        }

        // Update previous state
        previousState = currentState;
    }