# Direct child CoherenceSyncs

Objects with the `CoherenceSync` component can be connected at runtime to other objects with a `CoherenceSync` component to form a direct parent-child relationship.

For example, an item of cargo can be parented to a vehicle, so that they move together when the vehicle is in motion.

Keep in mind that on this page we deal with **direct** parenting of two `CoherenceSync` GameObjects. If it's not practical to parent a network entity directly to the root of another, see instead how to [deeply nest CoherenceSyncs](https://docs.coherence.io/1.1/coherence-sdk-for-unity/networking-state-changes/hierarchies-and-child-objects/coherencenode).

{% hint style="info" %}
When an object has a parent in the network hierarchy, its transform (**position** and **orientation**) will update in **local space**, which means its transform is relative to the parent's transform.
{% endhint %}

{% hint style="warning" %}
A child object will only be visible in a LiveQuery if its parent is within the query's boundaries.
{% endhint %}

## Implementation

Parenting network entities directly **doesn't require any extra work**. Any parenting code (i.e. Unity's own `transform.SetParent()` will work out of the box, without any need for additional action.

You can add and remove parent-child relationships at runtime – even from the Unity editor, by drag-and-drop.

### Effect on coherence LODs

If the child object is using LODs, it will base its distance calculations on the world position of its parent. For more info, see the [Level of detail](https://docs.coherence.io/1.1/optimization/level-of-detail#using-lods-with-connected-entities) documentation.

### Handling parent destruction

When the parent `CoherenceSync` is destroyed, by default its `CoherenceSync` children get destroyed together with it. This can be changed via the *Preserve Children* option on the parent, under *Advanced Settings*:

<figure><img src="https://976449006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4xmLLczbgaGVeoF6vews%2Fuploads%2F2OfRCEjjgRUcEiLmqZq8%2FCoherenceSync_PreserveChildren.png?alt=media&#x26;token=8b489d60-a053-4173-b018-b435505cf0bb" alt="" width="563"><figcaption></figcaption></figure>

When *Preserve Children* is enabled, if the authority destroys or disables the parent entity, child entities get unparented instead of being destroyed together with the parent. Those children will now reside at the root of the Scene hierarchy.

{% hint style="info" %}
For an example of direct child `CoherenceSync` components parenting and unparenting at runtime, check out the **First Steps** sample project, specifically [lesson 4](https://docs.coherence.io/1.1/learning-coherence/first-steps-tutorial/4-parenting-entities).

<img src="https://976449006-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4xmLLczbgaGVeoF6vews%2Fuploads%2Fyd2qZDOC5CzO9L37SyKL%2FPlayersOnPlatform.jpg?alt=media&#x26;token=b77f844a-4dd8-4f99-84da-c24b8216d8b8" alt="" data-size="original">
{% endhint %}
