Greetings again,
In my game, I would like to have a damage immunity system similar to The Binding of Isaac: Repentance and Terraria, where piercing attacks would only hit once each. This makes sure every projectile of the same type hits an enemy without damaging them every frame.
To achieve this, I opted to start out by giving each harmful object it’s own UID, which can be stored in an array to prevent further damage from that projectile.
So I threw together this system to make it so that every bullet that’s spawned in gets a UID:
It appears to be working… kind of. There’s a bit of an issue I’d like to point out:
As you can see where I circled, all of the bullets fired here have the same UID, which is not only not what I want, but inconsistent with the rest of the bullets being fired.
Also, despite not affecting the game in any way, I noticed that several numbers are sometimes just skipped entirely? This implies that the scene variable that increments the UID is updating when it shouldn’t?
Is there a way to fix this? The former issue in particular? Or do I just have to cut my losses and deal with it?