N
nired360
Guest
Hello everyone, i created a state machine for my character and am having a problem with my attack state, whenever i press the attack button my characters keeps on repeating the attack animation, here's the code incase it helps , thx !
switch (state)
{
case states.idle:
{
sprite_index = idle;
if (hsp != 0 ) and grounded = true state = states.run;
if key_attack and grounded = true state = states.attack;
if key_jump and grounded = true state = states.jump;
}
break;
case states.run:
{
sprite_index = run;
if (hsp = 0) and grounded = true state = states.idle;
if vsp < 0 and grounded = false state = states.jump;
if key_attack and grounded = true state = states.attack;
}
break;
case states.jump:
{
sprite_index = jump;
if (hsp = 0) and grounded = true state = states.idle;
if (hsp != 0 ) and grounded = true state = states.run;
}
break;
case states.attack:
{
sprite_index = tak;
instance_create_layer(x,y,"Collision_Layer",hitbox);
}
break;
}
while vsp > 0
{
sprite_index = jump;
image_index = 4;
break;
}
switch (state)
{
case states.idle:
{
sprite_index = idle;
if (hsp != 0 ) and grounded = true state = states.run;
if key_attack and grounded = true state = states.attack;
if key_jump and grounded = true state = states.jump;
}
break;
case states.run:
{
sprite_index = run;
if (hsp = 0) and grounded = true state = states.idle;
if vsp < 0 and grounded = false state = states.jump;
if key_attack and grounded = true state = states.attack;
}
break;
case states.jump:
{
sprite_index = jump;
if (hsp = 0) and grounded = true state = states.idle;
if (hsp != 0 ) and grounded = true state = states.run;
}
break;
case states.attack:
{
sprite_index = tak;
instance_create_layer(x,y,"Collision_Layer",hitbox);
}
break;
}
while vsp > 0
{
sprite_index = jump;
image_index = 4;
break;
}