It would be helpful to have a screenshot of your events.
How do you check if the enemies that should take damage are in the area? You could just use a hidden sprite object (or your attack sprite-object - if there is any) and check for collision. Or you could use the ‘distance between two objects’ condition. But it really depends on the game and the attack etc.
I see. So can you tell something about the shape of the damage area?
In general it is as I wrote above, you could check for collision with a sprite-object that represents your damage area, like:
or you could check for the distance between your character and the enemies (for example, if the distance is below 250 pixels while attacking, you reduce 40 hp from the enemies).
Btw in the examples enemies is an object group including different enemy objects.
but in this case wouldn’t just happen the same way?
if any entity of the group “enemies” is in collision
then subtract health from the group “enemies”
making so that every enemy on the game gets damage, no?
thank you very much for your help
could you elaborate a little more about the logic behind this code? i know i could just copy it but i really would like to understand how it works
First the event checks for collision of the enemies and the attack area sprite. The ‘Trigger once while true’-condition makes sure that the health points are reduced only once per collision and not with every frame.
The sub-event is a ‘for each’-block which reduces the 40 HP only for those enemies-objects which are in collision with the attack_area sprite. Without this, the points for all objects in the ‘enemies’ group would be reduced - that was probably the problem you had.
The ‘Take into account linked objects’-condition and the ‘change the text’-action are just additions to see the individual hp-values for each enemy-object. You don’t need them, unless you want to display the hp-value for your enemies.