Skip to content

Latest commit

 

History

History
92 lines (56 loc) · 3.03 KB

NetworkEntity.md

File metadata and controls

92 lines (56 loc) · 3.03 KB

NetworkEntity (client)

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.


Index

Properties

.id : string
.mine : boolean
.properties : Array.<Object>

Events

* => ([data])

Functions

send(name, [data], [callback])


Properties

.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.

Events

* [event] => ([data])

NetworkEntity will receive own named network messages.

Param Type Description
data object | array | string | number | boolean Message data.

Functions

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.

Callbacks

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.