UnitSynchronizer - stingray.UnitSynchronizer object reference - Stingray Lua API Reference
The UnitSynchronizer is a helper object that synchronizes the creation, destruction, position and rotation of units across multiple networked peers.
It provides a simplified, built-in system for synchronizing the most common modifications to game units, minimizing
the number of callbacks that you need to implement in the callback object you use to initialize your Network
object. However, if you want more detailed control over the way your units are synchronized, you may want to
code your own synchronization instead of using the UnitSynchronizer.
In order to use the UnitSynchronizer, the game objects you synchronize must be configured appropriately in
the .network_config data file you use to initialize the Network. See the networking documentation for details.
|
Retrieves the Unit object that corresponds to the game object with the specified game object ID.
|
Parameters self : | stingray.UnitSynchronizer | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
id : | integer | The game object ID of the unit to retrieve. |
Returns
|
Sets the game world in which the unit synchronizer should create and destroy units.
|
Parameters self : | stingray.UnitSynchronizer | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
world : | stingray.World | The game world in which the unit synchronizer should spawn units. |
Returns | This function does not return any values. |
You must call this
function before you can call any other functions of the UnitSynchronizer object.
|
spawn_unit ( self, type, unit_name, position, rotation ) : stingray.Unit
|
Parameters self : | stingray.UnitSynchronizer | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
type : | string | The type of game object to use for synchronizing this unit, as configured in the .network_config data file. |
unit_name : | string | The name of the unit resource that should be spawned. |
position : | stingray.Vector3? | The starting position for the new unit. If omitted, the unit will be spawned at the default position (the origin of the 3D coordinate system). The ? notation indicates that this type is optional: there may be zero or one instances of it. |
rotation : | stingray.Quaternion? | The starting rotation for the new unit. If omitted, unit will be spawned with a default rotation. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Returns
|
Retrieves the game object ID that corresponds to the specified Unit.
|
Parameters self : | stingray.UnitSynchronizer | Specifies the object instance that this function will act on. You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation. |
unit : | stingray.Unit | The unit whose game object ID will be retrieved. |
Returns integer |
The corresponding game object ID, if any.
|