Update Function in State Machine not stopping

Hey Guys,
so i want to return to the normal State of my State Machine after a certain period of Time. And i want the Timer to start from the beginning every Time i switch back to the other state. But switching back to the normal state is not stopping the timer from running. From what i understand about State Machine, the Update Function of a State that is not active should not be running. Can anybody help here?

Heres my code for jumping back to the normal State:

   public override void UpdateState(EnemyStateMachineManager enemy)
    {
        //start timer

        currentTime += Time.deltaTime;
        Debug.Log(currentTime);

        //go back to Normal
        if (currentTime >= startTime + maxDurationBeforeGoingBackToNormal)
        {

            currentTime = 0f;
            startTime = 0f;
            enemy.SwitchState(enemy.NormalState);

        }

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

You may edit your post above.

This is my position on finite state machines (FSMs):

I’m kind of more of a “get it working first” guy.

Your mileage may vary.

Hey Kurt, thanks for your feedback! I’ve edited the post. I’ve read your post and i see where you’re coming from. Would you suggest buying an assett for creating FSMs or just skipping them alltogether, until i can properly utilize them?

I don’t see ANY value in a generic FSM. It just doesn’t solve any actual problem that I can’t trivially solve by writing the precise FSM I need when I need it.

Your mileage may vary. If you like to “write framework code,” by all means, go nuts. I just don’t see any value in it.