bandman28
Member
I have a bomb exploding, and enemies in it's range.
I want the bomb to do damage only once to each enemy so that it doesn't keep subtracting from the enemies health.
I wrote this:
(this is in the bomb)
I also have code that destroys the bomb after exploding, so the array doesn't do anything else.
But when I play the game, the bomb doesn't show signs of doing any damage.
Is there any way to keep track of what enemies this bomb has hit, so that it does not repeatedly take damage from the enemy?
I want the bomb to do damage only once to each enemy so that it doesn't keep subtracting from the enemies health.
I wrote this:
(this is in the bomb)
GML:
//Create
damage = .5;
hit = [];
GML:
//Collision with enemy
var not_hit = true;
for (var i = 0; i < array_length(hit); i++) {
if (hit[i] = other) {
not_hit = false;
}
}
if (not_hit) {
other.hlth -= damage;
hit[array_length(hit)] = other;
}
But when I play the game, the bomb doesn't show signs of doing any damage.
Is there any way to keep track of what enemies this bomb has hit, so that it does not repeatedly take damage from the enemy?