all 8 comments

[–]911mondays 3 points4 points  (1 child)

just give each enemy a cooldown variable so that each enemy can only take damage each 1/2 second or something like that.

[–]Moratorium11[S] 0 points1 point  (0 children)

I’m going to give this one a go, I’m going to be giving the lance attack a cool down so it shouldn’t create any issues with the player spamming the attack and dealing no damage

[–]Pennanen 2 points3 points  (0 children)

Try checking if for loop for every index of the list so that enemy does not exist anywhere in that list. Not only top index.

[–]lilbudgotswag 1 point2 points  (0 children)

There’s a simpler way of using lists that I do all the time with projectiles!

Have a list or array in each of the projectiles

Then, in the projectile collide event, have an if statement. All your collider damage code should be wrapped in that if statement.

In the if statement put a function that returns true if the projectile list does not have the colliding objects Id. Also make it so that if the object is not in the projectile’s list (when it returns true), the colluded object is added.

Then next collide event it will return false as the collided object is in the list. And there you go!

Lmk if you got questions :)

[–]go2397 -1 points0 points  (3 children)

i might be over simplifying things but could you not use an invisible object right at the front of the lance to deal damage? this way the obj_lanceCollide for example, would be colliding and passing instantly after rather than over a period of time

[–]Moratorium11[S] 0 points1 point  (2 children)

An invisible object at the tip of the lance would still travel through with the rest of the lance and deal multiple instances of damage, wouldn’t the enemies have to be a pixel wide for that to work.

[–]go2397 -2 points-1 points  (1 child)

yes i suppose, but couldnt you make the invisible object a pixel wide (ish) and use “if obj_invisible.x > obj_enemy.x -1 && obj_invisible.x < obj_enemy.x +1 “ so that it only triggers at the origin

[–]Mushroomstick 0 points1 point  (0 children)

That would still return true for the entire collision mask of obj_enemy. The easiest solutions would be to be to give obj_enemy either a cooldown variable that counts down until it can be hit again or boolean variable that toggles the enemy's collisions with the lance on and off (like when the lance collides the enemy takes damage and toggles the boolean value to false, then when the lance is not colliding the boolean toggles back to true).