Guest User

FSM

a guest
Oct 31st, 2023
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. extends Node2D
  2.  
  3. var current_state: State
  4. var previous_state: State
  5.  
  6. func _ready():
  7. current_state = get_child(0) as State
  8. previous_state = current_state
  9. current_state.enter()
  10.  
  11. func change_state(state):
  12. if state == previous_state.name:
  13. return
  14.  
  15. current_state = find_child(state) as State
  16. current_state.enter()
  17.  
  18.  
  19. previous_state.exit()
  20. previous_state = current_state
  21.  
Advertisement
Add Comment
Please, Sign In to add comment