Parenting network entities
How to parent CoherenceSync objects to each other
How to parent CoherenceSync objects to each other
Out of the box, coherence offers several options to handle parenting of networked entities. While some workflows are automatic, others require a specific component to be added.
Generally there is a distinction if the parenting happens at runtime vs. edit time, and whether the two entities are direct parent-child, or have a complex hierarchy. See below for each case.
At runtime:
CoherenceSyncs as a direct child: when you create a parent-child relationship of CoherenceSync
objects at runtime.
Deeply-nested CoherenceSyncs: when you create a complex parent-child relationship of CoherenceSync
objects at runtime.
At edit time:
Nesting connected Prefabs assets: the developer prepares several connected Prefabs and nests them one to another before entering Play Mode. This covers both Prefabs in the scene and in the assets.
When preparing a CoherenceSync Prefab for use as a child object it is important to always configure the bindings so that position, rotation, and scale are bound. This will ensure that the proper transform state of the entity is maintained when it is parented to another CoherenceSync object.
Try it out in our First Steps interactive demo! Don't forget to also look at the explanations.