Skip to main content

NetworkEntityBehaviour

An abstract class in Root.Township, Alta.Networking.

Base class for game components that live on a NetworkEntity. Override its hooks to run code when the entity is set up, spawned by the server, or sent to a player.

Constructors​

MemberWhat it is
protected NetworkEntityBehaviour()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

1 private and internal field
MemberWhat it is
private NetworkEntity entityBacking field for Entity, filled from the same GameObject.

Properties​

MemberWhat it is
NetworkEntity Entity { get; }The NetworkEntity on the same GameObject, filled in at bake time.

Methods​

MemberWhat it is
virtual void Initialize()Called on both sides when the entity is initialized. Empty by default.
virtual void InitializeAsServer(SpawnData spawnData)Server: called once when the server sets up the entity, whether freshly spawned or loaded from a save, with its SpawnData. Empty by default.
virtual void OnConnected(Player player)Server: called when the entity is sent to a player, so you can send that player any extra state. Empty by default.
virtual void OnDisconnected(Player player)Server: called when the entity stops being synced to a player. Empty by default.