If the object does not require input or no client has input authority over it, null can be passed instead. The client to whom input authority was given will be able to provide input data for the object and (in addition to the Host or Server) is allowed to query that input structure in GetInput(). The input authority is assigned to a particular client by passing in their PlayerRef to the method this is optional. Fusion will correctly return the same object during re-simulation of predicted local spawns (assuming the prediction key matches), while authoritative spawns only happen in shared mode or on the Host, neither of which does re-simulation. In either case, Spawn should be called from FixedUpdateNetwork and it is ok to call during both Forward and Re-simulation stages. Other clients will receive the object eventually. In shared mode, State Authority is always assigned to the caller and, again, the instance is returned immediately.However, Fusion supports creation of a temporary local object for instant feedback - this is referred to as "Predictive Spawning". On a client in hosted or client/server mode, the default action is that nothing will happen and that the call will return null.Clients will receive the object as part of the next snapshot. On the server, in hosted or client/server mode, ownership (State Authority) of the spawned object is assigned to the server, and the object is created and returned immediately. var obj = Runner.Spawn(prefab, Vector3.zero, Quaternion.identity, Runner.LocalPlayer, MyOnBeforeSpawnDelegate, key) Īlthough any client can call Runner.Spawn(), the results will differ depending on the network topology. Only the prefab is a mandatory parameter, all others are optional. a prediction key of type NetworkObjectPredictionKey in case this is a predicted spawn.a delegate of type NetworkRunner.OnBeforeSpawned to run before replicating the object on the other instances.a PlayerRef to identify the client with input authority over the object.The parameters that can be provided to the method are: The Runner.Spawn() method on the Fusion NetworkRunner instance mimics the GameObject.Instantiate() method in Unity. The Runner.Spawn() method tells Fusion when and how to add a new object instance to the collective network state.ĭo NOT use Unity's built in GameObject.Instantiate() method for networked object, this will just create a local game object which is completely detached from the Fusion simulation loop with a broken network state. The NetworkObject is used by Fusion to assign a network-wide unique identifier so all clients can agree on which instance is which and correctly synchronize each networked object's state. be created using the Runner.Spawn() method.This page is a work in progress and could be pending updates.įor a GameObject to exist across the network, it has to:
0 Comments
Leave a Reply. |