S
Shaddy
Guest
Im coding a state maschine for my enemies and this is the code I set up for the Idle state
counter += 1;
y+=vsp+grv
x+= hsp*walkspd;
//Transition Trigger
if (counter >= room_speed *3)
{
var change =choose (0,1)
switch (change)
{
case 0: state= ENEMYSTATE.IDLE;
case 1: var hspr = choose (0,1)
switch(hspr)
{
case 0: hsp= -1
case 1: hsp= 1
}
}
}
the issue is at the moment it spins around like a beyblade and doesnt set to go to one direction... How could I code this slightly different so that the enemy decides to chose a side, and not beyblade?
counter += 1;
y+=vsp+grv
x+= hsp*walkspd;
//Transition Trigger
if (counter >= room_speed *3)
{
var change =choose (0,1)
switch (change)
{
case 0: state= ENEMYSTATE.IDLE;
case 1: var hspr = choose (0,1)
switch(hspr)
{
case 0: hsp= -1
case 1: hsp= 1
}
}
}
the issue is at the moment it spins around like a beyblade and doesnt set to go to one direction... How could I code this slightly different so that the enemy decides to chose a side, and not beyblade?