extension-photon-fusion

Namespace: fusion Language: Lua Type: Extension

Functions and constants for interacting with Photon Fusion

API

fusion.init

Type: FUNCTION Initialize Fusion.

Parameters

fusion.init_from_settings

Type: FUNCTION Initialize Fusion from game.project settings.

fusion.connect

Type: FUNCTION Connect Fusion.

Parameters

fusion.disconnect

Type: FUNCTION Disonnect Fusion.

fusion.reconnect

Type: FUNCTION Reconnect Fusion.

fusion.start

Type: FUNCTION Start Fusion sync.

fusion.stop

Type: FUNCTION Stop Fusion sync.

fusion.get_state

Type: FUNCTION Get connection state.

Returns

fusion.get_disconnect_cause

Type: FUNCTION Get disconnect cause.

Returns

fusion.join_or_create_room_random

Type: FUNCTION Join or create random room.

Parameters

fusion.join_room_random

Type: FUNCTION Join random room.

Parameters

fusion.join_room

Type: FUNCTION Join room.

Parameters

fusion.join_or_create_room

Type: FUNCTION Join or create room.

Parameters

fusion.create_room

Type: FUNCTION Create room.

Parameters

fusion.leave_room

Type: FUNCTION Leave room.

Parameters

fusion.is_connected

Type: FUNCTION Check if Fusion is connected.

Returns

fusion.is_running

Type: FUNCTION Check if Fusion has config and is connected.

Returns

fusion.is_started

Type: FUNCTION Check if Fusion is started. Fusion is considered started after a call to. fusion.start() has received a EventOnFusionStart event.

Returns

fusion.is_in_room

Type: FUNCTION Check if Fusion is in a room.

Returns

fusion.enable_debug

Type: FUNCTION Enable/disable debugging.

Parameters

fusion.register_scene_object

Type: FUNCTION Register a scene object.

Parameters

fusion.spawn

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

Returns

fusion.despawn

Type: FUNCTION Destroy a networked object.

Parameters

fusion.register_object

Type: FUNCTION Register an object.

Parameters

fusion.unregister_object

Type: FUNCTION Unregister a previously registered object.

Parameters

fusion.scene_change

Type: FUNCTION Change scene.

Parameters

fusion.rpc

Type: FUNCTION Send RPC.

Parameters

Returns

fusion.on_event

Type: FUNCTION Set event listener.

Parameters

fusion.get_local_player_id

Type: FUNCTION Get the player id of the local client

Returns

fusion.get_owner_id

Type: FUNCTION Get the player id of the current owner of an object

Parameters

Returns

fusion.has_authority

Type: FUNCTION Check if this client has authority over a game object. Use this to decide if user input should be handled or not.

Parameters

Returns

fusion.has_owner

Type: FUNCTION Check if an object has an owner

Parameters

Returns

fusion.want_authority

Type: FUNCTION Signal desire for the local client to own an object

Parameters

fusion.clear_owner_cooldown

Type: FUNCTION Explicitly clear the ownership cooldown

Parameters

fusion.set_send_rate

Type: FUNCTION Set the send rate of an object. This decided how much bandwidth to allocate

Parameters

fusion.set_local_send_rate

Type: 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

fusion.reset_send_rate

Type: FUNCTION Reset the send rate of an object.

Parameters

fusion.player_count

Type: FUNCTION Get player count

Returns

fusion.is_master_client

Type: FUNCTION Get if this client is the room’s master

Returns

fusion.get_rtt

Type: FUNCTION Get round trip time

Returns

fusion.network_time_diff

Type: FUNCTION Get raw offset between server time and local time. A positive value means the server clock is ahead of the local clock.

Returns

fusion.set_global_interest_key

Type: FUNCTION Set global visibility key for an object

fusion.set_area_interest_key

Type: FUNCTION Set area visibility key for an object

fusion.set_user_interest_key

Type: FUNCTION Set user visibility key for an object

fusion.set_area_keys

Type: FUNCTION Set area visibility keys

Parameters

fusion.add_user_key

Type: FUNCTION Add a user visibility key

fusion.remove_user_key

Type: FUNCTION Remove a user visibility key from an object

OWNERMODE_TRANSACTION

Type: VARIABLE OWNERMODE_TRANSACTION

OWNERMODE_PLAYERATTACHED

Type: VARIABLE OWNERMODE_PLAYERATTACHED

OWNERMODE_DYNAMIC

Type: VARIABLE OWNERMODE_DYNAMIC

OWNERMODE_MASTERCLIENT

Type: VARIABLE OWNERMODE_MASTERCLIENT

OWNERMODE_GAMEGLOBAL

Type: VARIABLE OWNERMODE_GAMEGLOBAL

STATE_DISCONNECTED

Type: VARIABLE STATE_DISCONNECTED

STATE_CONNECTING

Type: VARIABLE STATE_CONNECTING

STATE_CONNECTED

Type: VARIABLE STATE_CONNECTED

STATE_JOININGROOM

Type: VARIABLE STATE_JOININGROOM

STATE_INROOM

Type: VARIABLE STATE_INROOM

STATE_LEAVINGROOM

Type: VARIABLE STATE_LEAVINGROOM

STATE_DISCONNECTING

Type: VARIABLE STATE_DISCONNECTING

DISCONNECT_CAUSE_NONE

Type: VARIABLE DISCONNECT_CAUSE_NONE

DISCONNECT_CAUSE_DISCONNECTBYSERVERUSERLIMIT

Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYSERVERUSERLIMIT

DISCONNECT_CAUSE_EXCEPTIONONCONNECT

Type: VARIABLE DISCONNECT_CAUSE_EXCEPTIONONCONNECT

DISCONNECT_CAUSE_DISCONNECTBYSERVER

Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYSERVER

DISCONNECT_CAUSE_DISCONNECTBYSERVERLOGIC

Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYSERVERLOGIC

DISCONNECT_CAUSE_TIMEOUTDISCONNECT

Type: VARIABLE DISCONNECT_CAUSE_TIMEOUTDISCONNECT

DISCONNECT_CAUSE_EXCEPTION

Type: VARIABLE DISCONNECT_CAUSE_EXCEPTION

DISCONNECT_CAUSE_INVALIDAUTHENTICATION

Type: VARIABLE DISCONNECT_CAUSE_INVALIDAUTHENTICATION

DISCONNECT_CAUSE_MAXCCUREACHED

Type: VARIABLE DISCONNECT_CAUSE_MAXCCUREACHED

DISCONNECT_CAUSE_INVALIDREGION

Type: VARIABLE DISCONNECT_CAUSE_INVALIDREGION

DISCONNECT_CAUSE_OPERATIONNOTALLOWEDINCURRENTSTATE

Type: VARIABLE DISCONNECT_CAUSE_OPERATIONNOTALLOWEDINCURRENTSTATE

DISCONNECT_CAUSE_CUSTOMAUTHENTICATIONFAILED

Type: VARIABLE DISCONNECT_CAUSE_CUSTOMAUTHENTICATIONFAILED

DISCONNECT_CAUSE_CLIENTVERSIONTOOOLD

Type: VARIABLE DISCONNECT_CAUSE_CLIENTVERSIONTOOOLD

DISCONNECT_CAUSE_CLIENTVERSIONINVALID

Type: VARIABLE DISCONNECT_CAUSE_CLIENTVERSIONINVALID

DISCONNECT_CAUSE_DASHBOARDVERSIONINVALID

Type: VARIABLE DISCONNECT_CAUSE_DASHBOARDVERSIONINVALID

DISCONNECT_CAUSE_AUTHENTICATIONTICKETEXPIRED

Type: VARIABLE DISCONNECT_CAUSE_AUTHENTICATIONTICKETEXPIRED

DISCONNECT_CAUSE_DISCONNECTBYOPERATIONLIMIT

Type: VARIABLE DISCONNECT_CAUSE_DISCONNECTBYOPERATIONLIMIT

EVENT_OBJECT_READY

Type: VARIABLE EVENT_OBJECT_READY

EVENT_SUB_OBJECT_CREATED

Type: VARIABLE EVENT_SUB_OBJECT_CREATED

EVENT_OBJECT_DESTROYED

Type: VARIABLE EVENT_OBJECT_DESTROYED

EVENT_SUB_OBJECT_DESTROYED

Type: VARIABLE EVENT_SUB_OBJECT_DESTROYED

EVENT_OBJECT_OWNER_CHANGED

Type: VARIABLE EVENT_OBJECT_OWNER_CHANGED

EVENT_OBJECT_PREDICTION_OVERRIDE

Type: VARIABLE EVENT_OBJECT_PREDICTION_OVERRIDE

EVENT_LOBBY_STATS

Type: VARIABLE EVENT_LOBBY_STATS

EVENT_ROOM_JOINED

Type: VARIABLE EVENT_ROOM_JOINED

EVENT_ROOM_LEFT

Type: VARIABLE EVENT_ROOM_LEFT

EVENT_RPC

Type: VARIABLE EVENT_RPC

EVENT_SCENE_CHANGE

Type: VARIABLE EVENT_SCENE_CHANGE

EVENT_DESTROYED_MAP_ACTOR

Type: VARIABLE EVENT_DESTROYED_MAP_ACTOR

EVENT_INTEREST_ENTER

Type: VARIABLE EVENT_INTEREST_ENTER

EVENT_INTEREST_EXIT

Type: VARIABLE EVENT_INTEREST_EXIT

EVENT_FORCED_DISCONNECT

Type: VARIABLE EVENT_FORCED_DISCONNECT

EVENT_FUSION_START

Type: VARIABLE EVENT_FUSION_START

EVENT_CONNECTED

Type: VARIABLE EVENT_CONNECTED

EVENT_DISCONNECTED

Type: VARIABLE EVENT_DISCONNECTED