#Tagging Entities For Same Frame

24 messages · Page 1 of 1 (latest)

slate falcon
#

I'm trying to tag certain entities for a function that should execute later in the same frame (in Update) since others that execute on that same frame depend on it.
I can't insert tags with Commands because .insert would only apply after Update.
What would you do in my place?
Should I just put their entity numbers into a vec? (could be hundreds of entities)

silk elk
#

you could manually run apply_deferred right after that system, so that the component is added.
just make sure that all 3 systems ( apply_deferred and your other 2) are correctly ordered so that they run after each other.

or the other thing you could do is to just use events?

#

store the entity ID in the event and read the event in the other system as well as have a query in it. then get the entity out of the query

slate falcon
#

I'll try the apply_deferred next time I get to that project
Thanks

silk elk
slate falcon
slate falcon
#

I realized the reason I didn't do it in the first place (that's actually exactly what I'm doing with spawns, I just forgot cause I wrote it a few months back haha)
I'm actually marking the ones that should not despawn
which means I'll have to run over the query and for each event remove an answer from it or something, leaving me only with ones that weren't tagged as "not to despawn"
which means I'm probably better off with apply_deferred haha

#

I can't make the code compile

silk elk
slate falcon
# silk elk Well show the Code, maybe i can help

Thanks
It seems that functions that take &mut World can't take anything else
But if I run a function with &mut World after the function that determines which things should not despawn it does nothing

silk elk
#

But if I run a function with &mut World after the function that determines which things should not despawn it does nothing

#

are you running applied deferred in between?

#

and also, what do you mean with "should not despawn"? what exactly are you even trying to achieve? understanding that would make me be able to help you better

slate falcon
#

oh I didn't see that you responded

#

hold on, reading

slate falcon
slate falcon
# silk elk and also, what do you mean with "should not despawn"? what exactly are you even ...

alright, I'll try to provide more details:
I'm making a game with lots of numbered tiles
There could be a case in which I generate a new board with 49000 tiles instead of 50000
I wouldn't want to despawn everything and then spawn everything, considering I'll be using the exact same 49000 tiles for the smaller board
so, when building the smaller board I mark each tile that I use in the new one as "DoNotDespawn", and then in the despawner I call a query with all the ones not tagged with it, so that it will despawn them (I still don't want those thousand tiles to exist in the game world, since they'll slow down each query)

silk elk
slate falcon
silk elk
#

no i mean litteraly "apply_deferred", thats a system built into bevy that you can call whenever and that is being called by bevy itself after every schedule

silk elk
slate falcon