I have this POC where I’m testing bullet patterns, and I want to add a lifespan to bullets.
So here, I have a guy with various variables, one of them being bulLife. The plan is so that if I put any number in here (For example 1 for 1 second), then every bullet shot by the guy will only stay for a second, then it will be deleted.
The event above likely didn’t work because it has nothing in its condition except Trigger Once. That means, it only happens once, which is at the beginning of the scene. Instead of doing that, try putting that event as a sub-event of event where you spawn bullets.
Also if you want to gradually reduce the opacity of the bullet, giving it an effect of fading, you can try using the Opacity Tween.
In your first event, you’re setting the lifespan of bullet to the value of guy.Variable(bulLife).
The question is, which guy’s variable are you using? You’re not selecting the guy linked to each bullet. So GDevelop uses the first one in the list of all guy objects. You need to link them as a condition of the first event.
However, I’d question why you aren’t setting the bullet lifespan in the event that creates the bullet. I’m guessing at that point you know which guy it’s coming from, so there’s no fiddly little after events to worry about.
Why are you creating the link there? What are you doing? You need the link in the condition, as in all guys linked to bullet. How else will you filter out the correct guy object the bullet is linked to?
Also, think about it what you are doing. Think of the steps you are taking. Do they seem logical? As I explained, the in the first event you are not filtering the guy object to use.
Of course that won’t work; you are resetting the timer every single frame just before you check if it’s greater than the variable lifespan. Get rid of that first event completely, and just have the the second event and it’s subevent.