#Despawn has to be in an exclusive run set?

7 messages · Page 1 of 1 (latest)

compact smelt
#

I'm using iyes_loopless and I've run into a problem where it seems that system calling a despawn_recursive() from an entity commands can cause Bevy to choke with an entity does not exist error:

thread 'Compute Task Pool (3)' panicked at 'Attempting to create an EntityCommands for entity 58v0, which doesn't exist.'

I "solved" this by making a different game label where the system with the despawn code runs after other systems that might use the entities that were despawned.

Is that the intended behavior? My understanding was that despawn will queue entities to be despawned after all the other system updates so that it doesn't cause any conflicts with other systems. But clearly that's not the case, because otherwise this wouldn't cause a problem.

Perhaps this is a problem with using iyes_loopless since it seems like it mucks with the stages of things?

coral meteor
#

My understanding was that despawn will queue entities to be despawned after all the other system updates so that it doesn't cause any conflicts with other systems. But clearly that's not the case, because otherwise this wouldn't cause a problem.
Your interpretation of the intended behavior is correct

#

All commands are deferred to the end of the stage

#

If you queued up multiple despawn commands within one stage, they would all process at the end of that stage and try to despawn the entity multiple times - this might produce a warning, but itself isn't problematic behavior

#

However in this case, what's happening is that you're attempting to queue up a despawn command after the original despawn command has already processed at the end of its stage

#

Once the deferred commands get processed at the end of the stage, the entity no longer exists and you cannot queue any further commands against that entity

compact smelt
#

Thanks! I'm not quite sure I'm following though. Are you saying there is some path in my code that is causing a reference to an entity already despawned to have despawn called on it again?