A problem with melee attack

Could someone please aid me in this, i’ve been trying to implement a melee attack but couse of the way i’am doing it not only my sprite get’s afected but it gets affected multiple times, i’ve tryed to ad a invencibility frame but it does not work. Also my spites own attack afects him, could somebody check my code and tell me their opinion on the problem?.

1 Like

Looks like the issue is here:


Because the player and the enemy both “use” a projectile sprite, they both damage themselves and each other! I would try making a new sprite type like “playerSword” and another one “enemySword” and then checking for type playerSword touches enemy and enemySword touches player! That way the player isn’t effected by the playerSword and same for the enemy and enemySword!

Also I would change the sprite type of the curtain sprite to something other than player, maybe food or something, so that it isn’t also getting detected by the overlap check.