> For the complete documentation index, see [llms.txt](https://maraudical.gitbook.io/status-effects-framework/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maraudical.gitbook.io/status-effects-framework/2.0.0/other-support/netcode-for-gameobjects.md).

# Netcode for GameObjects

<figure><picture><source srcset="/files/fMRYzHXLY7pwdmq31M71" media="(prefers-color-scheme: dark)"><img src="/files/B2yZTl5HfuFSGMAA6Ii4" alt="" width="192"></picture><figcaption></figcaption></figure>

## Introduction

The Status Effect Framework now supports [Unity's Netcode for GameObjects](https://docs.unity3d.com/Manual/com.unity.netcode.gameobjects.html) package. This means it will be possible to synchronize Status Effects from servers to clients with ease. Just note that the system is **server authoritative**, and all logic related to [StatusVariables](/status-effects-framework/2.0.0/type-specifics/classes/statusvariable.md) should ideally only run on the server.

{% hint style="warning" %}
[Netcode for GameObjects](https://docs.unity3d.com/Manual/com.unity.netcode.gameobjects.html) must use version 1.8 or newer and the [Addressables](https://docs.unity3d.com/Manual/com.unity.addressables.html) package must also be used!
{% endhint %}

## Getting Started

To begin syncing Status Effects, simply replace any [StatusManagers](/status-effects-framework/2.0.0/type-specifics/classes/statusmanager.md) with a **NetworkStatusManager**. Functionally the NetworkStatusManager is the same as the regular [StatusManager](/status-effects-framework/2.0.0/type-specifics/classes/statusmanager.md) exept that the key difference is in how adding new Status Effects will work. Instead of passing in the [StatusEffectData](/status-effects-framework/2.0.0/type-specifics/scriptable-objects/statuseffectdata.md) to create a new [StatusEffect](/status-effects-framework/2.0.0/type-specifics/classes/statuseffect.md) with, the AddStatusEffect method will take in an [AssetReferenceT\<ScriptableObject>](https://docs.unity3d.com/Packages/com.unity.addressables@0.6/api/UnityEngine.AddressableAssets.AssetReferenceT-1.html) and return an awaitable task (either [Awaitable](/status-effects-framework/2.0.0/other-support/awaitable.md) or [UniTask](/status-effects-framework/2.0.0/other-support/unitask.md)) that outputs the created [StatusEffect](/status-effects-framework/2.0.0/type-specifics/classes/statuseffect.md). This is because Scriptable Objects cannot be sent directly over the network, so the asset GUID reference is sent over it instead.

In addition to adding the NetworkStatusManager, make sure that the GameObject it is added to also has a [NetworkObject](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/) component. <mark style="color:red;">**Status Effects will not sync if you do not add this**</mark>.

## Network Status Variables

In addition to the new NetworkStatusManager there are also a few classes that can replace the previous non-networked  [StatusVariables](/status-effects-framework/2.0.0/type-specifics/classes/statusvariable.md): **NetworkStatusFloat**, **NetworkStatusInt**, and **NetworkStatusBool**. The only difference between the NetworkStatusVariable and regular [StatusVariables](/status-effects-framework/2.0.0/type-specifics/classes/statusvariable.md) is that the base value and sign protected value will automatically sync across the network. There is a caveat to this however. Since [StatusVariables](/status-effects-framework/2.0.0/type-specifics/classes/statusvariable.md) are capable of being nested inside other classes or in arrays and lists, NetworkStatusVariables cannot. Similar to the base [NetworkVariable](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable/) class, <mark style="color:red;">**all NetworkStatusVariables must be in a**</mark> [<mark style="color:red;">**NetworkBehaviour**</mark>](https://docs.unity3d.com/2020.1/Documentation/Manual/class-NetworkBehaviour.html) <mark style="color:red;">**and not nested within anything**</mark>. Again, make sure that the GameObject with the [NetworkBehaviour](https://docs.unity3d.com/2020.1/Documentation/Manual/class-NetworkBehaviour.html) also has a [NetworkObject](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/) component.

{% hint style="info" %}
**Good to know:** If you still want to use non-networked [StatusVariables](/status-effects-framework/2.0.0/type-specifics/classes/statusvariable.md), you can still use the NetworkStatusManager in its [SetManager](/status-effects-framework/2.0.0/type-specifics/classes/statusvariable/setmanager.md) method.
{% endhint %}

Thats it! If you have other questions or find any bugs feel free to send me a message on Discord or add it to the issue tracker on GitHub.
