Namespace: fusion
Language: Lua
Type: Extension
Functions and constants for interacting with Photon Fusion
Type: FUNCTION Initialize Fusion.
Parameters
app_id (string)app_version (string)Type: FUNCTION Initialize Fusion from game.project settings.
Type: FUNCTION Connect Fusion.
Parameters
user (string)server (string)Type: FUNCTION Disonnect Fusion.
Type: FUNCTION Reconnect Fusion.
Type: FUNCTION Start Fusion sync.
Type: FUNCTION Stop Fusion sync.
Type: FUNCTION Get connection state.
Returns
number - StateType: FUNCTION Get disconnect cause.
Returns
number - CauseType: FUNCTION Join or create random room.
Parameters
create_room_options (table)matchmaking_options (table)Type: FUNCTION Join random room.
Parameters
matchmaking_options (table)Type: FUNCTION Join room.
Parameters
room_name (string)join_room_options (table)Type: FUNCTION Join or create room.
Parameters
room_name (string)create_room_options (table)join_room_options (table)Type: FUNCTION Create room.
Parameters
room_name (string)create_room_options (table)Type: FUNCTION Leave room.
Parameters
will_come_back (boolean)send_auth_cookie (boolean)Type: FUNCTION Check if Fusion is connected.
Returns
booleanType: FUNCTION Check if Fusion has config and is connected.
Returns
booleanType: FUNCTION
Check if Fusion is started. Fusion is considered started after a call to.
fusion.start() has received a EventOnFusionStart event.
Returns
booleanType: FUNCTION Check if Fusion is in a room.
Returns
booleanType: FUNCTION Enable/disable debugging.
Parameters
enable (boolean)Type: FUNCTION Register a scene object.
Parameters
scene (number)factory_url (string)owner_mode (number)id (string)Type: FUNCTION Create a networked game object. This will spawn a game object in the same. Way as when calling factory.create(). The function will also register the spawned object with Fusion as if manually calling register_object()
Parameters
factory_url (string)position (vector3) - Initial position of created game object
rotation (quat) - Initial rotation of created game object
scene (number) - The scene to which this object belongs
owner_mode (number) - Owner mode of spawned objectReturns
hash - Of the spawned game objectType: FUNCTION Destroy a networked object.
Parameters
id (string)Type: FUNCTION Register an object.
Parameters
scene (number)factory_url (string)owner_mode (number)id (string)Type: FUNCTION Unregister a previously registered object.
Parameters
id (string)Type: FUNCTION Change scene.
Parameters
index (number)sequence (number)data (string)Type: FUNCTION Send RPC.
Parameters
target_player (number) - 0 = all, specific PlayerId = targeted
data (string)
Returns
booleanType: FUNCTION Set event listener.
Parameters
listener (function)Type: FUNCTION Get the player id of the local client
Returns
number - Player id of the local clientType: FUNCTION Get the player id of the current owner of an object
Parameters
id (string) - Id of the object to get the owner forReturns
number - Player id of the object’s ownerType: FUNCTION Check if this client has authority over a game object. Use this to decide if user input should be handled or not.
Parameters
id (string)Returns
boolean - Returns true if the client has authorityType: FUNCTION Check if an object has an owner
Parameters
id (string) - Id of the objectReturns
boolean - If the object has an ownerType: FUNCTION Signal desire for the local client to own an object
Parameters
claim_ownership (boolean)id (string) - Id of the object to ownType: FUNCTION Explicitly clear the ownership cooldown
Parameters
id (string) - Id of the object to clear cooldown forType: FUNCTION Set the send rate of an object. This decided how much bandwidth to allocate
Parameters
send_rate (number)id (string) - Id of the object to send rate forType: FUNCTION
Set the local send rate divisor for an object. A value of 1 means the object sends every tick (highest rate). A value of 16 means it sends every 16th tick (lowest rate). This is a client-side optimization – the object still exists on all clients but consumes less bandwidth when you are not the active authority.
Parameters
send_rate (number)id (string) - Id of the object to send rate forType: FUNCTION Reset the send rate of an object.
Parameters
id (string) - Id of the object to reset send rate forType: FUNCTION Get player count
Returns
number - Number of playersType: FUNCTION Get if this client is the room’s master
Returns
boolean - True if this client is the room’s masterType: FUNCTION Get round trip time
Returns
number - Round trip time in secondsType: FUNCTION Get raw offset between server time and local time. A positive value means the server clock is ahead of the local clock.
Returns
number - Time diffType: FUNCTION Set global visibility key for an object
Type: FUNCTION Set area visibility key for an object
Type: FUNCTION Set user visibility key for an object
Type: FUNCTION Set area visibility keys
Parameters
keys (table) - Area keys to set. Stored as a table of key value pairs (area_key->send_rate)Type: FUNCTION Add a user visibility key
Type: FUNCTION Remove a user visibility key from an object
Type: VARIABLE OWNERMODE_TRANSACTION
Type: VARIABLE OWNERMODE_PLAYERATTACHED
Type: VARIABLE OWNERMODE_DYNAMIC
Type: VARIABLE OWNERMODE_MASTERCLIENT
Type: VARIABLE OWNERMODE_GAMEGLOBAL
Type: VARIABLE STATE_DISCONNECTED
Type: VARIABLE STATE_CONNECTING
Type: VARIABLE STATE_CONNECTED
Type: VARIABLE STATE_JOININGROOM
Type: VARIABLE STATE_INROOM
Type: VARIABLE STATE_LEAVINGROOM
Type: VARIABLE STATE_DISCONNECTING
Type: VARIABLE DISCONNECT_CAUSE_NONE
Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYSERVERUSERLIMIT
Type: VARIABLE DISCONNECT_CAUSE_EXCEPTIONONCONNECT
Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYSERVER
Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYSERVERLOGIC
Type: VARIABLE DISCONNECT_CAUSE_TIMEOUTDISCONNECT
Type: VARIABLE DISCONNECT_CAUSE_EXCEPTION
Type: VARIABLE DISCONNECT_CAUSE_INVALIDAUTHENTICATION
Type: VARIABLE DISCONNECT_CAUSE_MAXCCUREACHED
Type: VARIABLE DISCONNECT_CAUSE_INVALIDREGION
Type: VARIABLE DISCONNECT_CAUSE_OPERATIONNOTALLOWEDINCURRENTSTATE
Type: VARIABLE DISCONNECT_CAUSE_CUSTOMAUTHENTICATIONFAILED
Type: VARIABLE DISCONNECT_CAUSE_CLIENTVERSIONTOOOLD
Type: VARIABLE DISCONNECT_CAUSE_CLIENTVERSIONINVALID
Type: VARIABLE DISCONNECT_CAUSE_DASHBOARDVERSIONINVALID
Type: VARIABLE DISCONNECT_CAUSE_AUTHENTICATIONTICKETEXPIRED
Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYOPERATIONLIMIT
Type: VARIABLE EVENT_OBJECT_READY
Type: VARIABLE EVENT_SUB_OBJECT_CREATED
Type: VARIABLE EVENT_OBJECT_DESTROYED
Type: VARIABLE EVENT_SUB_OBJECT_DESTROYED
Type: VARIABLE EVENT_OBJECT_OWNER_CHANGED
Type: VARIABLE EVENT_OBJECT_PREDICTION_OVERRIDE
Type: VARIABLE EVENT_LOBBY_STATS
Type: VARIABLE EVENT_ROOM_JOINED
Type: VARIABLE EVENT_ROOM_LEFT
Type: VARIABLE EVENT_RPC
Type: VARIABLE EVENT_SCENE_CHANGE
Type: VARIABLE EVENT_DESTROYED_MAP_ACTOR
Type: VARIABLE EVENT_INTEREST_ENTER
Type: VARIABLE EVENT_INTEREST_EXIT
Type: VARIABLE EVENT_FORCED_DISCONNECT
Type: VARIABLE EVENT_FUSION_START
Type: VARIABLE EVENT_CONNECTED
Type: VARIABLE EVENT_DISCONNECTED