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

# Switch on Payload Type

**Switch on Payload Type** is a custom node that routes execution based on the *type* of data inside a payload. Think of it as `Switch on Enum`, but for payload types - one clean node instead of a long chain of casts.

<figure><img src="/files/BXisNcZIWWASdG5L2XNj" alt=""><figcaption></figcaption></figure>

***

### When to Use It

Use it when a single event tag can arrive carrying **different data types** (e.g. sometimes an `Integer`, sometimes a custom struct, sometimes an `Actor` reference), and you want to handle each case differently.

***

### Step 1: Add the Node

1. Right-click the graph and search for **"Switch on Payload Type"** (category **UES → Utilities**).
2. Connect the incoming **Payload** pin from your Custom Event to the node's **Payload** input.
3. Wire the node's execution input from your callback.

<figure><img src="/files/V2TveIpIASIQaMDPz3jU" alt=""><figcaption></figcaption></figure>

***

### Step 2: Add Your Cases

1. Select the node and open the **Details** panel.
2. Under **Pin Options → Case Types**, click **`+`** to add a case.
3. Pick the type for that case (a primitive, an `Object`/`Actor` class, a custom struct, or an array).<br>

   <figure><img src="/files/uH0gjGJgwBpQan6KWEm8" alt=""><figcaption></figcaption></figure>
4. The node rebuilds itself: each case gets its own **execution output** and a typed **Value** output with the unpacked data.

<figure><img src="/files/xPONoIuJ7HOEtpt2w5tP" alt=""><figcaption></figcaption></figure>

***

### Step 3: Handle Each Branch

The payload is tested against your cases **top to bottom**. The first type that fits fires its execution pin and delivers the unpacked data on that case's **Value** pin.

{% hint style="warning" %}
**Order matters!** Cases are checked in the order shown in the Details panel - exactly like a chain of Casts. Put **more specific** types (a child class) **above** more general ones (a base class), or the general type will match first and swallow the specific one.
{% endhint %}

***

### The Default Branch

The **Default** output fires when the payload matches none of your cases - including when:

* the payload is **empty** (a signal-only event),
* the payload type isn't in your case list,
* or an object reference inside the payload was destroyed by Garbage Collection (`null` / stale).
