# Entity references

coherence is able to network references to other instances of Networked Prefabs.&#x20;

To do so, network any variables or methods using `GameObject` or any `Component` type:

<figure><img src="/files/E3C84mWd6jmWOEPee9mh" alt=""><figcaption></figcaption></figure>

### Limitations

It's important to know about the situations when a Networked Prefab reference might become null, even though it seems like it should have a value:

* A client might not have the referenced entity in its CoherenceLiveQuery. A local reference can only be valid if there's an actual Entity instance to reference. If this becomes a problem, consider switching to using the [CoherenceNode](/2.2/manual/networking-state-changes/parenting/deeply-nested-entities.md) component or [Parent-Child relationships](/2.2/manual/networking-state-changes/parenting/direct-children.md) of prefabs, which ensures that that Entity stays part of the query.
* The owner of the Entity reference might sync the reference to the Replication Server before syncing the referenced Entity. This will lead to the Replication Server storing a null reference. If possible, try setting the Entity references during gameplay when the referenced Entities have already existed for a while.
* **Cyclic references** are **undefined behavior** for now. Therefore multiple entities created on the same Client that reference each other might never get synced properly. This is also holds true for references that exist through intermediate entities (A has reference to B has reference to C has reference A - cyclic).

In any case, it's important to use a defensive coding style when working with Entity references. Make sure that your code can handle missing Entities and nulls in a graceful way.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/2.2/manual/networking-state-changes/coherence-sync-references.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
