Networking
La référence est en anglais : elle est générée à partir des commentaires du code, écrits en anglais.
public static class NetworkingNamespace NodeWorld.Flux.
The network of the room: the owners of objects and the master, synced transforms, objects spawned for the room, and the server's clock.
Properties
masterId
public static int masterId { get; }The master of the room: the player in it for the longest time.
isMaster
public static bool isMaster { get; }The local player is the master of the room (false on the server).
serverTimeMilliseconds
public static int serverTimeMilliseconds { get; }The clock of the server, in ms (the same for every player, give or take the latency); wraps around like an int.
serverTime
public static double serverTime { get; }The clock of the server, in seconds.
Methods
Instantiate
public static GameObject Instantiate(GameObject template, Vector3 position, Quaternion rotation)Spawns a copy of template for the whole room, at position and rotation, and returns it at once. template is an object of the scene marked as a network template (the "Network template" box of its FL# Script component, in the editor): every player has it in the world. The server gives the copy a network id of its own in the room and tells every player, those who arrive later too, with its last synced state. Its scripts live as those of an object of the scene: Awake, Start, synced state, network events, ownership. The owner is the player who spawned it (the master for a copy spawned by a server script); when that player leaves, the copy stays and goes to the master. No limit on the count: only the 120 messages a second of each player slow a burst down.
Destroy
public static void Destroy(GameObject spawned)Removes a spawned copy (Networking.Instantiate) for the whole room: its scripts get OnDestroy everywhere. The owner of the copy, the master or a server script may do it.
IsSpawned
public static bool IsSpawned(GameObject gameObject)The object is a copy spawned by Networking.Instantiate (by any player or by the server).
IsOwner
public static bool IsOwner(GameObject gameObject)The local player owns the network state of the object (it is the one that sends it).
GetOwner
public static int GetOwner(GameObject gameObject)The owner of the object: the player that took it last, or the master when nobody did.
RequestOwnership
public static void RequestOwnership(GameObject gameObject)The local player takes the ownership of the object: its scripts (OnOwnershipRequest here, then on the current owner) may refuse. IsOwner is true at once unless refused here; refused by the owner, it goes back.
SyncTransform
public static void SyncTransform(GameObject gameObject, float updatesPerSecond = 20f)Synchronizes the transform of the object (it needs a network id in the scene): its owner sends it updatesPerSecond times a second, the other players follow it. 0 stops.
FlagDiscontinuity
public static void FlagDiscontinuity(GameObject gameObject)The next synced transform of the object is a jump (teleport): the others place it at once.
