# CoherenceNode

The `CoherenceNode` component is used to prepare a network entity that needs to be parented to another network entity at a **deep level** – that is, not as a direct child. You only need `CoherenceNode` if the object needs to be a child of a child, or more.

<figure><img src="https://content.gitbook.com/content/NnpDkLUgRAbq6m09r93U/blobs/iLM2zpEqZRcJYhvu9rtg/CoherenceNode.png" alt="" width="563"><figcaption><p>A CoherenceNode component</p></figcaption></figure>

The goal of the `CoherenceNode` component is to keep track of where the object is in the hierarchy, so when it's reparented by its owner coherence is able to replicate the same hierarchy structure on each connected Client.

However, as a user you don't need to do anything about it. You just apply the component to a network entity, and coherence will take care of the rest for you. Happy re-parenting!

{% hint style="info" %}
To get familiar with all parenting options, we strongly recommend to read the [Parenting network entities](https://docs.coherence.io/1.3/manual/parenting-network-entities) section.
{% endhint %}

## Inner workings

{% hint style="info" %}
This section is only interesting if you want to understand deeply how `CoherenceNode` works under the hood.
{% endhint %}

`CoherenceNode` works using two public fields which are automatically set to sync using the `[Sync]` attribute.

```csharp
[Sync] public string path;
[Sync] public int pathDirtyCounter;
```

The `path` variable describes where in the parent's hierarchy the child object should be located. It is a string consisting of comma-separated indexes. Every one of these indexes designates a specific child index in the hierarchy. The child object which has the `CoherenceNode` component will be placed in the resulting place in the hierarchy.

The `pathDirtyCounter` variable is a helper variable used to keep track of the applied hierarchy changes. In case the object's position in the parent's hierarchy changes, this variable will be used to help settle and properly sync those changes.

![](https://content.gitbook.com/content/NnpDkLUgRAbq6m09r93U/blobs/TsZaapC1onHiIp12iAet/CoherenceNode_SyncedProps.png)
