in a game where a machine gun is used for example … how can I check that every single bullet does its duty? I mean … hitting the target takes away the desired energy and all subsequent commands I want to add … be it impact effects sounds or whatever …
because I’m having severe difficulties … in the sense that however long I can use the for each function and how long I can put an object variable on the bullet that is a boolean hit … enemies sometimes lose energy but don’t die … and that’s it that it happens to only one enemy that all the rest of enemies acquire this unwanted power of immortality …
with this code I am afraid that the hit variable will be changed to all the bullets that have been created and not just to one
I’m wrong??? at the moment I create an object by assigning it a variable string = 0 when I then press FIRE for each bullet it will be with that variable 0 … is that correct? if during the journey ammo1 changes … and I have 20 in the game … all 20 will change ???
As a note, don’t delete an object and then reference it. That will cause errors in the way the game runs.
The event with the condition Ammo1 is in collision with Enemy will filter or reduce the list of Ammo1 and Enemy objects. This reduced list is what is used in the actions or in subevents when you refer to Ammo1 or Enemy.
This will do what you’re after, and is more efficient because it only repeats over the Ammo1 objects that have collided with an Enemy object (instead of all Ammo1 object as you had it):