Here's the general idea; I'm assuming a new FSM just to keep this solution isolated from the rest of your unknown setup:
Below, I assume that you have access to that character-idle boolean, and I refer to it as "[char-idle]", whatever it is.
- State1: "Wait for Idle" (Start State) -- checks for [char-idle]==true every frame, and fires FINISHED once/if true. Transition: FINISHED --> "Reset Idle Time"
- State2: "Reset Idle Time" -- resets a float variable "IdleStartTime" to current time, and Transitions to "Charge" on FINISHED.
- State3: "Charge" -- (1) check bool [char-idle] EVERY FRAME and if FALSE, transition to "Wait for Idle" (if TRUE do nothing), (2) Check difference between "IdleStartTime" and current time EVERY FRAME; if >= X-seconds, transition to "Regenerate", else, do nothing. UPDATE: Fixed this by each of these checks happening every frame. Unless your [char-idle] is a global variable, may need to split this into 2 states, due to action limitations.
- State4: "Regenrate" -- Regenerate character's energy, and transition to "Wait for Idle"
This should do it, if implemented correctly.
Additional Note:The reason you cannot use "Wait" anywhere in this solution, is because during that wait period, the character could leave and re-enter Idle mode and you would never know, giving the sneaky bastard a regen, when not deserved