UniObject
UniBaseObject
is the base code of all objects and allows the synchronization of all objects without additional code.
To create an object there are several ways to do it, on the server you can place it on the scene before launching, or drag it from the prefab during execution, but also use the function (Instantiate). And on the client side you can only use the function.
Client and Server :
Field
ushort Id
Identification of the object on the network.
ItemObject item
Reference item of the object.
UniHand hand
This object is grabbed by this hand.
Method
UniObject.Destroy(UniObject uniObject)
Allows to destroy a synchronized object. (
UniObject
)
SendAction(triggerAction _action)
Allows to synchronize any behavior of the object with all players, function called from the heir.
override void DoAction(triggerAction triggerAction)
Reserved function has the inheritance with
override void DoAction(triggerAction triggerAction)
which allows to define the behavior according to the actiontriggerAction
.
this function is executed on all clients on the object in question.
override void OnDrop()
Called on all clients as soon as the object is dropped by a player.
override void OnGrab()
Called on all clients as soon as the object is caught by a player.
Client :
Méthodes
UniObject.Instantiate(ItemObject item, Vector3 position, Quaternion rotation)
Allows to create on the network a synchronized object, for that it is necessary a
itemObject
which comes from the database because the prefabs do not have their item referenced.
override void OnLocalDrop()
Called on the client whose object he dropped, before sending it.
override void OnLocalGrab()
Called on the client whose object he caught, before sending it.
Server :
Instantiate
To be able to create a synchronized object it is enough that the variable
ItemName
referenced and that the item has been created in the database, and just instantiate on the scene as any non-synchronized object.