I am still in the learning phase so this is probably trivial for the advanced developers among you.
I tried looking for the answer but I couldn't find it. Probably I am not using the correct keywords.
Basically, I am trying to assign a "health bar" to an enemy. The advice I read was to avoid the UIDs. I am using a global variable instead that gets incremented every time an enemy is created. It goes something like this:
1- Create enemy.
2- Increment global_var.
3- Assign global_var to enemy.local_var
4- spawn a health bar.
5- assign enemy.local_var to health bar.local_var.
6- Pin health bar to global var.
Am I guaranteed that steps 2 and 3 (part of the same event) will happen without interruption? Can another enemy creation event happen in a different thread and cause the global_var to be incremented between steps 2 and 3?