#Writing to IEnableableComponent is not working as expected

1 messages · Page 1 of 1 (latest)

verbal heart
#

Context:

  • I have a EnableAble Tag NewlySpawnedTag for marking entity as newly spawned (to make sure i do stuff to that entity when it first spawned: setting position, add animation clips, ...).
    -First System NewlySpawnedTagClearSystem to clear that tag, this system lay in InitSystemGroup
  • Second System AnimationClipInfoInitSystem to Add AnimClip Info for every Entity marked as "Newly spawned" and this system lay in FixedStepSim... => run after the clearer system above.
  • Currently only one Entity Player affected by 2 above systems (for easy testing), this Player lay in Subscene and have NewlySpawnedTagAuthoring attach to it (then the tag got baked into that Player).

Problem:
As you see in the picture, the anim clip init first then Tag cleared, which is not as my expectation.
I thought 1st system would run first, disable the tag then 2nd system won't work due to the fact that the tag got disabled.

pliant sphinx
#

Is this entity coming from a subscene?

#

your NewlySpawnedTagClearSystem is probably executing before scene entities are loaded

#

you should probably put this into simulation as well

#

i.e. your update looks like this
NewlySpawnedTagClearSystem
SceneSystemGroup -> Entity Created
AnimationClipInfoInitSystem -> Anim Clips Init
NextFrame
NewlySpawnedTagClearSystem -> Cleared Tag

#

so yeah either run your NewlySpawnedTagClearSystem in simulation (before fixed update)

#

or make it update after SceneSystemGroup in initialization

verbal heart
pliant sphinx
#

no, subscenes load async

#

it might take multiple frames before a subscene loads

verbal heart
pliant sphinx
#

once a subscene is loaded from disk, that's where it's copied into the world

verbal heart
#

Due to what you just said about subscene, im confused now

pliant sphinx
#

i.e. the entities from the subscene are now created in the world

verbal heart
verbal heart
#

this is what i want to reply

pliant sphinx
#

it happens after all systems are created - scene loading is handled by systems, so it cant happen before systems exist

#

it could happen 2 hours into you playing the game

#

you can load and unload subscenes as you walk around the world

verbal heart
#

so why in my case, SceneSystemGroup creates Entities from sub scene does not take multiple frame to perform as you said before?

pliant sphinx
#

not sure what you mean

#

are you asking why your subscene isn't taking multiple frames to load?

pliant sphinx
#

either it's really small or you are testing with an open subscene in the editor so it's already loaded

verbal heart
pliant sphinx
#

in build it will take multiple frames

#

pretty much always unless it's real real tiny

#

close your subscene and you will have pretty close to build conditions

#

but regardless the issue here isn't the async nature of hte subscene

#

it's just your system order

verbal heart
#

Ok but i am still concerned:
SubScene (when not preloaded) take multiple frames to be loaded, which mean my Player Entity (as mentioned in my post) may take multiple frames to be really exists in the World.
So if a System that does not RequireForUpdate<PlayerStuff> but still access PlayerStuff then can't find component Exception occured?

#

And the subscene Loading, creating Entity from that subscene is handled by SceneSystemGroup, right?

verbal heart
pliant sphinx
#

i do have a whole subscene loading pipeline that can require X subscenes to be loaded before simulation ticks to avoid this

#

but the default behaviour is, if you have an entity in a subscene and you are accessing it directly in a system

#

you need requireforupdate