extends pc.ScriptType
NetworkEntity is a pc.ScriptType, which is attached to a pc.ScriptComponent of an pc.Entity that needs to be synchronised between server and clients. It has unique ID, optional owner and list of properties to be synchronised. For convenience, pc.Entity has additional property: entity.networkEntity
.
.id : string
.mine : boolean
.properties : Array.<Object>
* => ([data])
send(name, [data], [callback])
.id : string
Unique identifier.
.mine : boolean
Whether this entity is related to our User.
.properties : Array.<Object>
List of properties, which should be synchronised and optionally can be interpolated. Each property object
has these properties:
Param | Type | Description |
---|---|---|
path | string |
Path to a property. |
interpolate | boolean |
If value is type of: number | Vec2 | Vec3 | Vec4 | Quat | Color , then it can be interpolated. |
ignoreForOwner | boolean |
If true then server will not send this property updates to an owner. |
* [event] => ([data])
NetworkEntity will receive own named network messages.
Param | Type | Description |
---|---|---|
data | object | array | string | number | boolean |
Message data. |
Send named message to a server related to this NetworkEntity.
Param | Type | Description |
---|---|---|
name | string |
Name of a message. |
data (optional) | object | array | string | number | boolean |
JSON friendly message data. |
callback (optional) | responseCallback | Callback that will be fired when response message is received. |
responseCallback [callback] => (error, data)
Param | Type | Description |
---|---|---|
error | null | [Error] |
Error provided with with a response. |
data | null | object | array | string | number | boolean |
Data provided with a response. |