G
Gunslito
Guest
Hello guys, I'm new here, this is not my native language so excuse me if I mess up with some words
I've a really annoying problem, when I try to use a state machine it executes every script of every case, even if the variable is different.
The thing is that as you can see if for example, the var "State" is equal to "stand" all cases will execute no matter what,
the var gconfig is configs.normal but the scripts "scr_movement, scr_collision and scr_animations executes 2 times because they're on gconfig=configs.death too, why is this happening?
I'm so sorry for bothering you with this question, thanks in advance for your help!
I've a really annoying problem, when I try to use a state machine it executes every script of every case, even if the variable is different.
enum states{stand,walk,transition,fly,flap,attack,swim,death}
state=states.stand
enum configs{normal,death}
gconfig=configs.normal
state=states.stand
enum configs{normal,death}
gconfig=configs.normal
switch(gconfig)
{
case configs.normal:
{
scr_inputs();scr_movement();scr_collision();scr_animations();
switch(state)
{
case states.stand: scr_stand();break;
case states.walk: scr_walk();break;
case states.transition: scr_transition();break;
case states.fly: scr_fly();break;
case states.flap: scr_flap();break;
case states.attack: scr_attack();break;
case states.swim: scr_swim();break;
}
}
case configs.death: scr_movement();scr_collision();scr_animations();
switch (state)
{
case states.death: scr_death(); break
}
}
{
case configs.normal:
{
scr_inputs();scr_movement();scr_collision();scr_animations();
switch(state)
{
case states.stand: scr_stand();break;
case states.walk: scr_walk();break;
case states.transition: scr_transition();break;
case states.fly: scr_fly();break;
case states.flap: scr_flap();break;
case states.attack: scr_attack();break;
case states.swim: scr_swim();break;
}
}
case configs.death: scr_movement();scr_collision();scr_animations();
switch (state)
{
case states.death: scr_death(); break
}
}
The thing is that as you can see if for example, the var "State" is equal to "stand" all cases will execute no matter what,
the var gconfig is configs.normal but the scripts "scr_movement, scr_collision and scr_animations executes 2 times because they're on gconfig=configs.death too, why is this happening?
I'm so sorry for bothering you with this question, thanks in advance for your help!