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.
- Listed in Networking and servers
Constructors
| Member | What it is |
|---|---|
ExampleBehaviour() | Creates an ExampleBehaviour with default values. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private NetworkEntity entity | The entity the syncs belong to. |
private Transform head | Transform turned by the look direction. |
private float health | Current health value. |
private ISync healthSync | The health sync. |
private ISync lookDirectionSync | The look direction sync. |
private float maxHealth | Maximum health, used to scale the synced fraction. |
Methods
6 private and internal methods
| Member | What 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. |