Adds a state_duration to FSM.gd

main
Ervan Lefevre 2 years ago
parent a673356992
commit f2648f6c3c
  1. 10
      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)

Loading…
Cancel
Save