Dr_Nomz
Member
I have a sword swing that I want to damage all enemies that get caught in it's swing, but I want them to ONLY take damage from it once, instead of getting damaged for every frame of it that touches them.
This is the current setup I have, makes it so you can only hit one enemy per swing, which I don't want.
How it works is it checks if the sprite is colliding with the enemy, and if it is it creates a hit indicator and passes the damage script to the enemy, then stopping the attack from causing more damage per frame by setting attack to 0.
How do I get the instance ID of the enemies it touches in the current swing so it doesn't damage a single enemy more than once while it exists? (Basically so I can hit 50 enemies in one hit, but they all only get hit once each, in this case for 30 damage, and only 30 damage)
Code:
///CREATE
attack = 1;
///STEP
var collision_enemy = instance_place(x,y,par_Enemy);
if collision_enemy && attack == 1{
with collision_enemy{
instance_create(collision_enemy.x,collision_enemy.y,obj_Hit_Detector_2);
scr_Enemy_Damage(obj_Sword_Swing_1);
}
attack = 0;
}
How it works is it checks if the sprite is colliding with the enemy, and if it is it creates a hit indicator and passes the damage script to the enemy, then stopping the attack from causing more damage per frame by setting attack to 0.
How do I get the instance ID of the enemies it touches in the current swing so it doesn't damage a single enemy more than once while it exists? (Basically so I can hit 50 enemies in one hit, but they all only get hit once each, in this case for 30 damage, and only 30 damage)