Bullet's Life span

Hello everybody,
I was wondering how can be possible to give a life span time for very single bullet(let say, it will dissapear in 2 seconds). To be honest, I have no clue.
When I was toing around with Timers and Time, I had the feeling, that they are only global variables.
Even thou, I would be able to code that kind of problem in MonoGame, I just sadly have no clue, how to do that in GDevelop.

Thanks for any kind of help.
Have a nice day. :slight_smile: :slight_smile:

I’m not at my system right now but you can make remove it after it is so far from a object instead of time based. But again, I don’t know if that works in your case. Will be interesting to see how others handled it. I haven’t had to use oject variables yet to get that figured out. But I assume by use of object variables in some manner.

Hi. Well I was thinking about the same solution with the distance, but that seems to me quite hacky, especially while the character moves.

Good point about character moving. Nothing hacky about it, after all basic balistics would more less go by distance effected by things like spin bullet characteristics, wind speed, gravity, and other atmosphere characteristics. But based on the character moving you would want it to use a reference point of where it left the weapon at time of fire.
One thing to keep in mind, though I don’t know how important it is with modern systems and simple games are the amount of objects in the game and processes effecting them.

You can simply use object variables with the expression +1*TimeDelta() and For Each Object event to make a timer for each bullet and check the value of the object variable:

Thank you for both of your posts guys, both of them were really informative and I’ll try both of the solutions.

Np, although I haven’t tried it, I think ddabrahim hit the nail on the head.