C
Coleman K
Guest
Hello i am still very much a beginner and am having trouble with my attack state. I have it to where a hitbox spawns with my sPlayerAttack animation but once I press my attack key my player stops and the attack animation loops continuously and I lose control. I'm assuming i'm just not understanding how to get back to my normal state or missing something simple.
Here is my normal state code:
and here is my attack code:
Here is my normal state code:
Code:
scr_get_input();
walksp = 3;
grv = 0.3;
accel = 0.2;
var move =(key_right - key_left) * walksp;
hsp = approach(hsp,move,accel);
vsp = vsp + grv;
if (place_meeting(x,y+1,oWall)) and (key_jump)
{
vsp = -4
}
if key_attack
{
state = state.attack;
}
// Animation
if (hsp != 0)
{
image_xscale = sign(hsp);
}
if (hsp == 0)
{
sprite_index = sPlayerIdle;
}
else
{
sprite_index = sPlayerRun;
}
scr_collision();
Code:
hsp = 0;
vsp = 0;
sprite_index = sPlayerAttack;
image_speed = 1;
if (image_index >= 0)and (image_index <= 3)
{
with(instance_create_depth(x,y,0,oHitBox))
{
image_xscale = other.image_xscale;
}
}