# Actions

The **Photon** module comes with a set of **Actions** that complement **Game Creator**'s. All actions can be used on any other module

{% hint style="warning" %}
Most of the Actions won't work if you are not connect to the Photon Service unless you have **offline mode** activated.
{% endhint %}

## Synchronizing Actions

Synchronizing Actions it's just as easy as a single click. Once the module it's installed you will notice a new tab called "**Network Settings**" below the *Action's Inspector* in order to make this work just go ahead and enabled the option "**Sync Actions**" that's pretty much it (well that was actually 2 clicks).

{% hint style="warning" %}
This requires to be within a **room** to work. Nothing happens if not.
{% endhint %}

{% hint style="danger" %}
If you are *synchronizing* **actions** some times you might need to use target **Invoker** instead of **Player**
{% endhint %}

![(Example of the built-in sync actions inspector)](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-28b7392b8b437152d23fe80f7e04c3f85195d28b%2Fsync_actions.gif?alt=media)

Once you enabled **Sync Actions** you can select the [targets](https://njg.gitbook.io/gc-modules/~/drafts/-LGavgvIRvIu9eDV2NNm/primary/photon-network/photon-network/overview#targets) you want to synchronize with.

{% hint style="info" %}
Notice that this will add a **Photon View** component to the game object.
{% endhint %}

## Action Photon Connect <a href="#action-photon-connect" id="action-photon-connect"></a>

Allows you connect to the Photon Service, parameters:

* **Game Version**: this client's version number. Users are separated from each other by game version (which allows you to make breaking changes).
* **Methods:** this action allows you to connect using 3 different method types:
  * **UsingSettings**: Connect to Photon as configured in the PUN settings
  * **Region**: Connects to the Photon Cloud region of choice.
  * **BestCloudServer**: Connect to the Photon Cloud region with the lowest ping.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-8371a3b579d8c6c385443177210688f85395b849%2FActions1_01.png?alt=media)

{% hint style="danger" %}
Connecting to the **Photon Cloud** might fail due to:

\- **Invalid AppId** calls: OnFailedToConnectToPhoton. check exact AppId value

\- **Network issues** calls: OnFailedToConnectToPhoton

\- **Invalid region** calls: OnConnectionFail with DisconnectCause.InvalidRegion

\- **Subscription CCU limit reached** calls: OnConnectionFail with DisconnectCause.MaxCcuReached. also calls: OnPhotonMaxCccuReached
{% endhint %}

## Actions Photon Disconnect <a href="#actions-photon-disconnect" id="actions-photon-disconnect"></a>

Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnectedFromPhoton on completion.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-5f83936e6072870039163227519607754660774e%2FActions1_03.png?alt=media)

## Action Photon Instantiate <a href="#action-photon-instantiate" id="action-photon-instantiate"></a>

Instantiate a prefab over the network. There is 2 types of instantiations:

* **Player Object**: the owner of the object is the player. Normally when player disconnects all instantiated player objects will be destroyed.
* **Scene Object**: the owner of the object is the scene. The object will always be there unless someone destroys it.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-ce0ab9faaae063f9f6f10f6b12f5dded89b04363%2FActions1_04.png?alt=media)

{% hint style="warning" %}
This prefab needs to be defined in **Prefabs list** from **Photon Preferences Settings** or located in the root of a "Resources" folder.
{% endhint %}

## Action Create Room <a href="#action-create-room" id="action-create-room"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-4686542e2cc57ccd1dc82258e202bd46289a0c0b%2FActions1_02.png?alt=media)

## Action Join or Create Room <a href="#action-join-or-create-room" id="action-join-or-create-room"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-bd46c86dbe16c74114d00b2c9faa9b4433a28b25%2FActions1_05.png?alt=media)

## Action Join Room <a href="#action-join-room" id="action-join-room"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-cb23b33d49e37a021862fa3780daaf2fd18c6b0a%2FActions1_07.png?alt=media)

## Action Kick Player <a href="#action-kick-player" id="action-kick-player"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-b611d7f773e08c7cc82709be98733b0b0445a428%2FActions1_08.png?alt=media)

## Action Leave Room <a href="#action-leave-room" id="action-leave-room"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-ef2341df697de3a77345214d1e6b7ad8077b0d36%2FActions1_09.png?alt=media)

## Action Reconnect <a href="#action-reconnect" id="action-reconnect"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-39f1b6fb93e844b05b05cc605bd14aad16c707eb%2FActions2_03.png?alt=media)

## Action Reconnect and Rejoin <a href="#action-reconnect-and-rejoin" id="action-reconnect-and-rejoin"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-a59671e6575e33f5ff9c803edfbcba695d419bca%2FActions2_04.png?alt=media)

## Action Rejoin Room <a href="#action-rejoin-room" id="action-rejoin-room"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-15d3c045b838821ec14c9189756a74862e86d07d%2FActions2_05.png?alt=media)

## Action Send Photon RPC <a href="#action-send-photon-rpc" id="action-send-photon-rpc"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-b2799d7e52722a8936e6862e23221be8f56690ad%2FActions2_07.png?alt=media)

## Action Score <a href="#action-score" id="action-score"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-e085bdf92abf124708335e84490f5c8c19a5799e%2FActions2_02.png?alt=media)

## Action Player Property <a href="#action-player-property" id="action-player-property"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-2de4d388fa437a22da7843a246bdf11079c25670%2FActions2_01.png?alt=media)

## Action Room Property <a href="#action-room-property" id="action-room-property"></a>

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-e2344a47a0f8dca5da5b0e1d2deff6f0569f592f%2FActions2_06.png?alt=media)

## Action Start Timer

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-9869db6af1040dea406f75b8885b6ce211553cd6%2FActions3_02.png?alt=media)

## Action Photon Change Text

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-7137c2f8383a2a6358a75229898d970e7fed1615%2FActions3_01.png?alt=media)
