Building a second lose condition help


  • Posts: 5
Hello Everyone
Super new to this community, but I am in need of some help. I would appreciate anyone's help with an issue I am having trying to build a game.

So I am trying to endless spaceship shooting game, but I am having trouble trying to figure out how to make two lose conditions.
I have one lose condition working where if the player collides with an enemy the player loses a life. Yay that at least works! :D

However, the second lose condition I am trying to create is when an enemy gets past the player then the player loses another life.

Instead the point counter in my game is counting each "killed" enemy that has left the screen as point. Now it is to my understanding that reason you have them "killed" when they have exited the scene is so you don't have a large number of enemies out of frame and inevitably crash the game.

Ideally I would like it to where once the life counter hits zero it will trigger a game over or a restart, but I just am unable to crack this problem.

If you look the screenshots I included you will see what my custom "scene manager" scene behavior is doing to my exiting enemies and the "lose a life" event for the player I was trying to trigger.
Again any help would be appreciated either with screenshots or Youtube video links (preferably in English) as to how to created the losing condition I want.

Thank You and have a great day.


  • *
  • Posts: 1363
i have difficulties undertsanding you. I am there for guessing.
You want to have a game over screen when lifes reach 0?
And you loose a life when an enemy leaves the screen "behind" you`?



  • Posts: 5
Hello Bombini
First of all thank you for the quick response.

Yes you are guessing correctly that is what I want to happen.

But as I mentioned currently when my enemies leave the screen the point counter I have set up is counting those enemies as kills and the score keeps going up.


  • *
  • Posts: 2230
Let's say it's a vertical top-down shooter. When the y-centre value of an enemy becomes greater than the player y-value you want to remove a life from the player but you need to use a boolean to make sure it only happens once per enemy.

If y-centre of self is greater than y-centre of PLAYER
If BEHIND PLAYER (attribute) = false
Decrement PLAY LIVES by 1

As for the score issue. Only increment the score if BEHIND PLAYER equals false when the enemy is killed.


  • Posts: 5
Hello Jeffrey
Thank You  for your reply and insight  to my post.

So would the solution you are suggesting be a scene behavior or an actor behavior that I give my enemies?


  • *
  • Posts: 2230
Having it as an actor behaviour would probably be a simpler approach.


  • Posts: 5
Thanks Jeffrey.
Do you mind taking a look at the attached screenshots to see if I understood you correctly.
My game is a endless x-centre type of game so you will see x instead of y.
If I did it wrong do you mind sending a screen shot of what it should look like.
Thank You again for your help and support.


  • Posts: 5
Greetings Again Jeffrey

First of all thank you for all of your support leading up to this point. But I am still having a bit of trouble with this lose condition.

So when I designed my game I gave my "player" character the ability to fire a projectile. However, this ability is now affecting the last line of code you suggested because now when my enemies are killed it is deducting lives from my player. So to try and combat the issue I tried adapting your code to a "enter or leaves the scene  or screen" actor event for my enemies. (see attachment)

 Should I maybe create two separate events one specifically for when my killed by the projectile actor and then one for when my enemies have left the scene?

Thank you again and I appreciate the help.


  • Posts: 217
This code looks good so I guess problem is somewhere else. Can you post all events for this actor?


  • *
  • Posts: 2230
'Actor' needs to be assigned to something.

You don't need the 'otherwise if' statement but that's not the problem.

What code runs when the actor dies?