Netcode for GameObjects

Introduction

The Status Effect Framework now supports Unity's Netcode for GameObjects 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 should ideally only run on the server.

Getting Started

To begin syncing Status Effects, simply add a NetworkStatusManager to an object that can recieve StatusEffects. If upgrading a GameObject already using regular StatusManagers, you can still add a NetworkStatusManager as under the hood it will function identically. One thing to note is that all StatusEffects are automatically added to the .

In addition to adding the NetworkStatusManager, make sure that the GameObject also has a NetworkObject component attached. Status Effects will not sync if you do not add this.

Network Status Variables

In addition to the new NetworkStatusManager there are also a few classes that can replace the previous non-networked StatusVariables: NetworkStatusFloat, NetworkStatusInt, and NetworkStatusBool. The only difference between the NetworkStatusVariable and regular StatusVariables is that the base value and sign protected value will automatically sync across the network. There is a caveat to this however. Since StatusVariables are capable of being nested inside other classes or in arrays and lists, NetworkStatusVariables cannot. Similar to the base NetworkVariable class, all NetworkStatusVariables must be in a NetworkBehaviour and cannot be nested within anything. Again, make sure that the GameObject with the NetworkBehaviour also has a NetworkObject component.

Good to know: If you still want to use non-networked StatusVariables, you can still use the NetworkStatusManager in its SetManager method.

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.

Last updated