#Instantiate in Scene

1 messages · Page 1 of 1 (latest)

stable minnow
#

Hello everyone,

in the project I'm working on, due to the current setup (online multiplayer with NetCode for Entities, ghost prefabs need to be referenced basically in the first subscene loaded, and that subscene won't be unloaded) it is necessary that when a scene (for a track) is unloaded quite a few entities get destroyed as well. So far (with Entities v0.51), a custom Tag was used to tag all entities that require this cleanup, however since destroying via query requires all children to be included as well, this currently doesn't work anymore after the refactoring to upgrade to Entities v1.0. I could dig deeper in how I could assign this tag to all children as well, however in the long run this could cause the issue that some entities are not tagged properly and linger around.
Instead I thought it might be easier to "move" the freshly instantiated entities into the subscene that actually will be unloaded (i. e. the one of the track) so that the entities will implicitly be destroyed. I tried achieving this by manually assigning the SceneSection and SceneTag of an existing entity (either a spawner or a singleton I know exists), but this doesn't work either, they still created inside the first subscene that got loaded. It doesn't matter if I use a Entities.ForEach or a IJobEntity (in both cases using a command buffer).
(All affected entity prefabs are referenced from an entity (i. e. at edit time from a GameObject) in the first loaded subscene and thus have their scene association (SceneSection and SceneTag) set up accordingly.)

How can I adjust the scene of an instantiated entity?

#

And shortly after posting I figured out a problem on my side: I was checking the client world and not the server world, however the entities appear on the client side via NetCode, and it seems like the scene association is not transferred, but properly created on the server side. x.x