Class: Actor

Photon.LoadBalancing.Actor(name, actorNr, isLocal)

Summarizes a "player" within a room, identified (in that room) by ID (or "actorNr"). Extend to implement custom logic.

Constructor

new Actor(name, actorNr, isLocal)

Parameters:
Name Type Description
name string Actor name.
actorNr number Actor ID.
isLocal boolean Actor is local.

Methods

getCustomProperties() → {object}

Returns custom properties.

Returns:
Custom properties.
Type
object

getCustomProperty(name) → {object}

Returns custom property by name.

Parameters:
Name Type Description
name string Name of the property.
Returns:
Property or undefined if property not found.
Type
object

getCustomPropertyOrElse(name, defaultValue) → {object}

Returns custom property by name or default value.

Parameters:
Name Type Description
name string Name of the property.
defaultValue object Default property value.
Returns:
Property or default value if property not found.
Type
object

getRoom() → {Photon.LoadBalancing.Room}

Actor's room: the room initialized by client for create room operation or room client connected to.

Returns:
Actor's room.
Type
Photon.LoadBalancing.Room

isSuspended() → {boolean}

Returns true if actor is in suspended state.

Returns:
Actor suspend state.
Type
boolean

onPropertiesChange(changedCustomProps, byClientopt)

Called on every actor properties update: properties set by client, poperties update from server. Override to update custom room state.

Parameters:
Name Type Attributes Description
changedCustomProps object Key-value map of changed properties.
byClient boolean <optional>
true if properties set by client.

raiseEvent(eventCode, dataopt, optionsopt)

Raises game custom event.

Parameters:
Name Type Attributes Description
eventCode number Identifies this type of event (and the content). Your game's event codes can start with 0.
data object <optional>
Custom data you want to send along (use null, if none).
options object <optional>
Additional options
Properties:
Name Type Description
options object Additional options
Properties
Name Type Attributes Default Description
interestGroup number <optional>
The ID of the interest group this event goes to (exclusively).
cache Photon.LoadBalancing.Constants.EventCaching <optional>
EventCaching.DoNotCache Events can be cached (merged and removed) for players joining later on.
receivers Photon.LoadBalancing.Constants.ReceiverGroup <optional>
ReceiverGroup.Others Defines to which group of players the event is passed on.
targetActors Array.<number> <optional>
Defines the target players who should receive the event (use only for small target groups).
webForward boolean <optional>
false Forward to web hook.

setCustomProperties(properties, webForwardopt, expectedPropertiesopt)

Sets custom properties.

Parameters:
Name Type Attributes Default Description
properties object Table of properties to set.
webForward boolean <optional>
false Forward to web hook.
expectedProperties object <optional>
Table of properties expected when update occurs. Use null as value if you expect the property to not exist. (CAS : "Check And Swap")

setCustomProperty(name, value, webForwardopt, expectedValueopt)

Sets custom property.

Parameters:
Name Type Attributes Default Description
name string Name of the property.
value object Property value.
webForward boolean <optional>
false Forward to web hook.
expectedValue object <optional>
Property value expected when update occurs. (CAS : "Check And Swap")

setName(name)

Sets actor name.

Parameters:
Name Type Description
name string Actor name.