Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 9BitStrider |
#FSM States
enum {BEAM, APPEAR, IDLE, LILSTEP, RUN, JUMP, SLIDE, CLIMB, CLIMB_TOP, HURT, FALL, DEAD, LEAVE}
func change_state(new_state):
state = new_state
match state:
BEAM:
new_anim = 'beam'
Getting an “Expected end of statement after expression” error on the line containing ‘match’ when porting my game from 3.1 alpha to 2.1.5.
Is there an equivalent for the above function so I can continue to use a finite state machine?
Seems I need to chain a bunch of IF statements for this to work. MATCH is a 3.0 addition.
9BitStrider | 2018-12-02 20:43
Hi, you are correct… in Godot 2 you must use if … elif … else … like in python. There are other questions in this forum that states the same. Please, can you post your finding as an answer and mark it as best? so question does not remains unanswered.
p7f | 2018-12-02 22:16
If you don’t want to use tons of elifs, you could also use Dics. At least if it’s something akin to your example. At least if you as many states as you describe.
coffeeDragon | 2018-12-03 11:26