From f2648f6c3c33042fab4dd16fbb169a82f4d37afb Mon Sep 17 00:00:00 2001 From: Ervan Lefevre Date: Sat, 30 Sep 2023 14:15:50 +0200 Subject: [PATCH] :sparkles: Adds a state_duration to FSM.gd --- scripts/ia/fsm.gd | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/ia/fsm.gd b/scripts/ia/fsm.gd index 643eda6..6b589ad 100644 --- a/scripts/ia/fsm.gd +++ b/scripts/ia/fsm.gd @@ -8,17 +8,20 @@ var states = ['idle'] var current_state = null var previous_state = null var next_state = null +var state_duration = 0 func set_states(new_states): self.states = new_states func _ready(): + pass + +func _physics_process(delta): if current_state == null: next_state = states[0] + _transition() + return - _transition() - -func _physics_process(delta): if "before_state" in root: root.call("before_state", delta) @@ -43,6 +46,7 @@ func _transition(): if on_exit_state_method in root: root.call(on_exit_state_method) + state_duration = 0 var on_enter_state_method = "on_enter_" + current_state + "_state" if on_enter_state_method in root: root.call(on_enter_state_method)