The global variable associated with level termination

In my game when the number of bullets ends, the player will lose. How do I make the last bullet continue toward the target before the end of the level associated with the number of the global variable?

Hi, there is a condition ‘number of object instances on the screen’

If the number of bullets of your player is 0 + there is no bullet on the screen anymore → game over.


Yes, I thought about that but sometimes I need the bullet (ball) to stay inside the screen to see where it will land in the end.
by the way, regarding the physical movement of the ball, is there a condition such as the stability or termination of the physical movement for any shape? for example To perform a level-ending action?

I am not sure if I understand your question. Do you mean with physical movement that your ball has the physics-behavior attached and that you want the movement to stop at the end of the level? If so, there is an action that allows you to activate or deactivate a behavior. (object with physics attached → behvior → De/activate a behavior)

No, I meant if the physical movement of the last ball stops, I want to end the level

Again, I am not sure what exactly you mean by physical movement. If you just apply a force (not moving the object with physics-behavior) there is a condition: object → movement using forces → object is stopped (no forces applied on it).

When I throw the ball it hits and bounces and will keep moving until it comes to rest.
Now, when the last ball lands, I want to end the level with a loss because the target was not hit
Is that clear now?

So I assume you are using the physics-behavior (so far you did not really confirm that).

There are conditions for the velocity of the object. If the velocity is 0 you can do some action.

Yes, I use physics behavior
There is more than one ball on the screen with different speeds, I cannot finish the level with one of the balls with a speed of 0, and there are other balls moving

You could try a “for each”-event, but maybe there is a better way to do it.

Edit: a ‘pick all objects’-condition should also work.

This will not work because if the condition is executed before the shots are finished, the player will lose and still have shots left.
I want to finish the level with the last shot

Well, I have not much information about your game. As far as I understand it - based on your questions -, you want the game to end if the player has no shots left and the balls in the scene are not moving anymore. Which part of combining both conditions gives you trouble?

Look when I shoot the last ball I need to wait if the last ball will hit the target or not but the player will lose before waiting for where the last ball will go that because the global variable of the number of balls is set to zero it means out of balls

Now, I see. The ‘game over’- action is triggered before the last ball stops. I assume we are just talking about a few seconds. You could use the ‘wait’-action for that. In case the ball still hits the target, the game should proceed.

1 Like

well what condition i should use after the action ( wait) is finished to lose level if the ball didn’t hit the target or stopped

The condition would be that your bullet variable is equal to 0 and the velocity of the balls is equal to 0.

I have tried the wait-action and it seems that it does not work very well, so I would suggest that you use a timer instead. You take both of the above mentioned conditions and unpause a timer that you initiated at the beginning of the scene.
After a certain time passed the game-over action is triggered. If the bullet variable is increased (for example because the ball still hit the target) the timer is paused and reset again.

It works, but it feels a bit clunky, so I hope that someone else can give a better suggestion.

Thanks for your answers
I have some ideas to solve that but i need to time to do that if i find the solution i will reply for you THANK YOU VERY MATCH AGAIN