{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Switch on Int in Unreal Engine 5 C++UE Docs

The Blueprint Switch on Int node is a plain C++ switch statement. Each integer case becomes a case label and the node's Default pin becomes default.

Blueprint node & C++ equivalent

C++
switch (Value)
{
  case 0: /* ... */ break;
  case 1: /* ... */ break;
  default: /* Default */ break;
}

What does the Switch on Int node do?

Switch on Int routes execution based on an integer value, sending the flow to the matching numbered output pin. If no pin matches the value, execution falls through to the Default output. It is the cleanest way to branch on a known set of integer states without chaining many Branch nodes.

The C++ equivalent

Use a switch (Value) statement where Value is your int32. Each numbered pin becomes a case 0:, case 1:, and so on, and the Default pin becomes the default: label. Remember the break; after each case so execution does not fall through into the next, which is a behavior the Blueprint node does not have.

Common mistakes

Forgetting break; is the classic C++ switch bug; without it, one case continues into the next, unlike the isolated outputs of the Blueprint node. Also note that C++ switch only works on integral and enum values, which is exactly why Switch on Int maps to it so directly.

Frequently asked questions

What is the C++ equivalent of Switch on Int in Unreal?+

A switch (Value) statement, with each integer output pin as a case label and the Default pin as default. Add break; after each case.

Why does my C++ switch run multiple cases?+

You are missing a break; at the end of a case, so execution falls through to the next one. Add break; to isolate each case like the Blueprint outputs.

Related Flow Control nodes

View all Flow Control nodes →