> For the complete documentation index, see [llms.txt](https://easy-event-manager.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easy-event-manager.gitbook.io/documentation/examples/usage-of-payload.md).

# Usage of Payload

How to use the Payload obje

{% hint style="danger" %}
Network Environment

Keep in mind when using **UObjects** as payloads that they're **not replicated**, you either have to make your own replication for UObjects or use a replicated **Actor** (although this **isn't recommended**). If you choose to use Actors as payloads, make sure to destroy it if it's not in use anymore!

*We are recommending to use the`Message`input instead to transfer any simple informations!*
{% endhint %}

{% hint style="info" %}
Make sure you have read the[ Implementation Guide](/documentation/implementation/getting-started.md) before proceeding with any examples for optimal results!
{% endhint %}

1. Bind the event `SaveScore` in BeginPlay():

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2Fs82estjsnMVhhF2CdfoO%2Fimage.png?alt=media&amp;token=7aa83d77-1802-4a2a-8360-3b1a8f19394d" alt=""><figcaption><p>Add it to your Blueprint</p></figcaption></figure>

2. Implement[^1] the [`OnEventCalled()`](/documentation/functions/on-event-called.md) event and add one of the two code examples:

{% hint style="info" %}
It is recommended to use **Interfaces** instead of casting!
{% endhint %}

{% tabs %}
{% tab title="Casting" %}

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2FzKbj6sA1GS1mjIzdkni1%2Fimage.png?alt=media&amp;token=5d5be179-6376-402f-9e76-22e4d3cb9553" alt=""><figcaption><p>Quick way with casting, not recommended for large scale<br>(Click on the image for original resolution)</p></figcaption></figure>
{% endtab %}

{% tab title="Interface" %}

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2FOoq4vkBpSD3TjulAUujr%2Fimage.png?alt=media&amp;token=02200509-8bb2-4273-9f34-926c511d6789" alt=""><figcaption><p>Using Interfaces is recommended to avoid unnecessary dependencies<br>(Click on the image for original resolution)</p></figcaption></figure>

#### Interface Setup

1. Create a new **Blueprint Interface** and add a new function which has the same variables as your Payload as outputs.&#x20;

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2FIzraLLhuyhzHBliuMePv%2Fimage.png?alt=media&amp;token=cd8efdf6-5f4d-4f2c-ad04-ab02b00df836" alt=""><figcaption><p><em>Optionally add a boolean named "Success" which can be used instead of <code>HasInterfaceImplemented()</code></em></p></figcaption></figure>

2. Implement the Interface to your Payload

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2F6nq0MZysnDlh8J25cgL0%2FPayloadInterface.png?alt=media&amp;token=e42c1b7c-2eae-4cdc-9d53-a806cf089348" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

Done! Now you can use [`CallEvent()`](/documentation/functions/call-event.md) everywhere you want and pass a [`BPO_MyPayload`](/documentation/examples/create-a-new-payload-object.md) to it like this:

{% hint style="info" %}
If you cache a reference to a Payload for any reason, make sure to clear the variable as it won't be collected by the Garbage Collector otherwise.
{% endhint %}

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2Ffiaj6YAHpRtQjBk9CyfC%2Fimage.png?alt=media&amp;token=4623ca74-63d8-4fff-a45d-d25b6d984b6b" alt=""><figcaption><p>For this example I placed this into the Level Blueprint</p></figcaption></figure>

<figure><img src="https://3743917652-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F461QZtnJljYazCvCp6z0%2Fuploads%2FvrJACPolBrIFmxPsBwWL%2Fimage.png?alt=media&amp;token=c3f71809-7332-4cd0-85a5-02f715ad93cd" alt=""><figcaption><p>Print result </p></figcaption></figure>

[^1]:
