Lightmind
Member
I've got a moving, jumping , and attacking player. He can attack on the ground fine, but when I jump and attack in midair, he freezes in midair, mid-animation, and im not sure why. Any help appreciated. This is my script:
Script code:
Sorry for not much information!
GML:
if (attack) state = PLAYERSTATE.ATTACKSLASH;
Code:
function PlayerState_Attack_Slash(){
hsp = 0;
// Start of the attack
if (sprite_index != spr_player_atk) {
sprite_index = spr_player_atk;
image_index = 0;
ds_list_clear(hit_by_attack);
}
// Use attack hitbox and check for hits
mask_index = spr_player_atkHB;
var hitByAttackNow = ds_list_create();
var hits = instance_place_list(x, y, obj_enemy, hitByAttackNow, false);
if (hits > 0) {
for (var i = 0; i < hits; i ++) {
// If this instance has not yet been hit by this attack
var hitID = hitByAttackNow[| i];
if (ds_list_find_index(hit_by_attack, hitID) == -1) {
ds_list_add(hit_by_attack, hitID);
}
}
}
ds_list_destroy(hitByAttackNow);
mask_index = spr_player;
if (animation_end()) {
sprite_index = spr_player;
state = PLAYERSTATE.FREE;
}
canattack = false;
alarm[0] = room_speed * 0.2;
}