Skip to main content

ExampleBehaviour

A class in Root.Township, Alta.Networking.

Example code showing how to set up syncs with SyncFactory. Not a component and not used by the game.

Constructors​

MemberWhat it is
ExampleBehaviour()Creates an ExampleBehaviour with default values.

Fields​

6 private and internal fields
MemberWhat it is
private NetworkEntity entityThe entity the syncs belong to.
private Transform headTransform turned by the look direction.
private float healthCurrent health value.
private ISync healthSyncThe health sync.
private ISync lookDirectionSyncThe look direction sync.
private float maxHealthMaximum health, used to scale the synced fraction.

Methods​

6 private and internal methods
MemberWhat it is
private void Initialize()Creates a health sync read by clients and a look direction sync that clients write and read.
private void InitializeAsServer()Adds the server write for health and makes the look direction sync read and relay.
private void OnClientReadHealth(IPlayer player, Stream stream)Reads health as a 0 to 1 fraction of maxHealth.
private void OnClientReadLookDirection(IPlayer player, Stream stream)Reads a direction and turns the head to face it.
private void OnClientWriteLookDirection(IPlayer player, Stream stream)Writes the head's forward direction.
private void OnServerWriteHealth(IPlayer player, Stream stream)Writes health as a 0 to 1 fraction of maxHealth.