#Proper way to set transform on instantiated prefabs in DOTS?

1 messages · Page 1 of 1 (latest)

supple lake
#

Are there any tricks to setting the transform on instantiated entities in DOTS? It seems like setting the LocalTransform component alone can lead to popping. I'm guessing I need to set all transform related components at the same time?

quartz anvil
#

you only need LocalTransform. everything else will be updated by Transform group

sonic radish
#

it'll appear in the world at 0,0,0 for a frame before transform system runs

#

if you're using ECB you should usually set the LocalToWorld as well

nova bane
#

One other obstacle you may run into when instantiating a prefab through an EntityCommandBuffer: as a side effect of the recent Transform system changes is that the transform values are all packed into a single component instead of separate Translation/Rotation/Scale components. In order to set the transform for a newly-instantiated instance (which doesn't exist yet, at ECB recording time), you must provide an entire LocalTransform object; there's no way to say "set the position to XYZ, but keep the prefab's rotation and scale".

We're working on a way to fix this in a future release, but in the meantime one workaround is to use a ComponentLookup<LocalTransform> to read the prefab entity's LocalTransform, modify as needed, and pass the modified value to EntityCommandBuffer.SetComponent<LocalTransform>(myNewEntity, modifiedPrefabTransform)

quartz anvil