HI,
how can I add +1 id for each enemy created?
in the past I used the enemy vision link to calculate the enemies on the field and add the value.
Now I no longer need enemy vision and would like to add the value for each enemy created subsequently.
this is what I used previously
At the beginning of the scene - change scene variable MaxEnemy ID =1
You could set the id to the number of nemici on the scene - something like InstancesInSceneCount(nemici) - (sorry, I can’t remember the exact function, and I’m away from my game dev machine).
Do this in an action straight after the enemy is created (and so in the same event).
Ah, then my suggestion may not work if multiple nemici are created at the same time.
Instead, you could to keep track of the latest id value (say a scene var named latestNemiciId). Then:
create an event with the nemici just spawned an object condition
then create a For each instance of nemicias a subevent, with an action to set nemici.id = latestNemiciId and a second action to add 1 to latestNemiciId.
Maybe I’m wrong but I think the just spawned an object just tells you if the spawner just spawned an object. It picks the spawner not the spawned object.
I’ve used this in the past. It checks if the ID is the default value of zero. I believe spawners can only spawn 1 object at a time. If you have multiple spawners then you would need to use for each object.
Is nemici the spawner or the spawned object. Only the spawner needs the spawn behavior. Try changing the just spawned an object to the spawner object. Everything else looks good.
It’s not this object was spawned, it’s this object spawned an object. Similar but opposite.