Guest User

FSM

a guest
Oct 20th, 2023
2,836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 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. current_state = find_child(state) as State
  13. current_state.enter()
  14.  
  15. previous_state.exit()
  16. previous_state = current_state
  17.  
Advertisement
Add Comment
Please, Sign In to add comment