Enemy hit not registering correctly

Hi guys,

I am creating a game that has multiple enemies so I made a group, and when an enemy is hit I update the variable to +1, but the problem is when I hit one enemy, then the second one 2 times, the second enemy is deleted, as I put that the variable needs to be 3, so that the enemy can take 3 hits before gone.

Can anyone help me, so that the variable applies, so when I hit one enemy 2 times it only applies to that enemy, and not all of them combined?

please see the screenshoot below,


Is “Enemy” a group or an object? You are changin a scene variable “EnemyHit” and taking the info from a scene variable to say if “Enemy” will be deleted or not. If another enemies are taking the info from that scene variable too so, they will be deleted. I suggest you to use object variable for every kind of enemy to take the info (so you would add 1 to an object variable of every type of enemy if the ball is colliding with an enemy).

It is in a group, as I plan to add multiple enemies, but I tried also as an object, it is not working for me… any advice?

I tried it that way, but I was not able to implement it, do you have a example so I can use it as a reference?

Thank you!

I tried this an it works perfect

You have to adapt it to your game. Maybe if there are a lot of balls at the same time in your game that hit your enemies, you should try it without “trigger once”.

1 Like

Thank you @Points! so it is best to use objects instead of the group… ok thank you!

Also, I have multiple enemies (copies of one object, and I think that is causing the issue), wished there was a way to use one object and duplicate it and treat it as 1 enemy each, but I guess that is not possible for now.

When I created that example, I put a lot of objects from each enemy and they all respond as an individual enemy (the rocket collision only adds 1 to the variable of the specific object it was hitting). Isn’t it working for you?

Ok, great to hear, I will try and let you know if that worked :slight_smile: Thank you!

This helped me fix it, thank you very much @Points! If you ever need help, please feel free to ask :slight_smile:

All the best and keep safe, and happy holidays!

Good to hear that, we are to help each other. Happy holidays!