UID (Unique Identifiers) not working properly (SOLVED)

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:
image
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?

The action that is calling your function is using harmfulThings. I think that should be bullet. As is, I think it is sending a list with all harmfulObjects. The list probably only has the just created bullets plus any object that’s in the scene for the other objects in the harmfulObjects group.

In your function, you have a trigger once. I would remove it. It works fine if there’s only 1 bullet shot at a time but when it shoots 3, I believe the trigger once is preventing the uid from being increased more than once.

There’s something weird happening to the 1st objects that are on the left. I’m wondering if that’s where the missing uids are.

1 Like

It appears that this was in fact the issue, I changed it to use bullets to narrow down it’s choices and it seems to be working! Thanks for the input

1 Like