Enemies in platform game

Hello I’m having a little problem with managing the enemies in my game.

I have to main problems :

1 - I created a life to the enemies. They die after being hit 5 times.
But this life is contained into a variable which destroy the enemies when it’s empty.
I only want the enemy I shot to disapear, not all the enemies on the scene.
Is there a way to do that other that creating a variable for each enemy ?

2 - The game is a platform game where the enemies will shoot the player when he comes near.
I want the enemy to always be turned on the side of the Player.
But I can’t use the angle option because then the Enemy will be turned into a weird angle.
I want the enemy to have a normal animation when the player is on it’s right and I want to flip the animation when the
Player goes on the right of the enemy.
Is that possible ?

I link the code for the 1st problem.

Thanks in advance for your answers !

Hello :slight_smile:

No, you need object variables :neutral_face:
But you don’t have to waste time creating every variable for every instance, just do a right click in the object (the main object, in the right window) and open its properties, you can add the default values of life, attack, etc. Then every instance you add will have these default values. You can do it with an action too, as you are doing (there are no object conditions, so every object will be affected):

Conditions: At the beginning of the scene Actions: Do = 5 the variable Life of Enemy
If you do it through actions, you’ll have to set the default values when creating new Enemies.

Yes, and you are explaining how to do it :laughing:

Conditions: Position X of Enemy is <= Player.X() (you can add a Trigger once condition here too, but it will not help a lot, I think) Actions: Flip Enemy horizontally: no

Conditions: Position X of Enemy is > Player.X() (you can add a Trigger once condition here too, but it will not help a lot, I think) Actions: Flip Enemy horizontally: yes

Oh thanks I’ll try that when I’m gonna have some time !

For the second point, I kinda know how it was supposed to happen, but I didn’t knew what I have to use in the code !

Thanks for telling me !

Well I tried to use the properties and I created a variable EnemyLife. But then when I load the game it doesn’t work. The ennemies doesn’t appear and I think it’s because they consider the enemy doesn’t have life at all. And I checked and put the variable EnemyLife to 5 but it didn’t worked…

Any ideas ?

if you are adding the life at the start of the scene it might be considering you have no life before the life is added therefore not creating the enemy.

Instead of it adding the health at the start of the scene set the initial value to 5, therefore the enemy will always have health even if it has not been created yet.

If any of the enemys require a different health you can then + and - values from the initial value

and just popped into my head when creating objects make sure you set the z-order of it as iv had it where the object has been created but its hidden behind the background or another object so im guessing when it creates an object its default z-order is 1