{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

MultiGate Node in Unreal Engine 5 C++UE Docs

The Blueprint MultiGate node routes execution to a different output each time it is hit. In C++ you track an index member and switch on GateIndex++ % N to cycle through outputs.

Blueprint node & C++ equivalent

C++
// .h
int32 GateIndex = 0;

// .cpp — route to the next output each call
switch (GateIndex++ % 3)
{
  case 0: OutputA(); break;
  case 1: OutputB(); break;
  case 2: OutputC(); break;
}

What does the MultiGate node do?

MultiGate fans one execution input out to several outputs, sending the flow to a different output pin each time it fires. With looping enabled it wraps back to the first output after the last, cycling endlessly. It is handy for round-robin behavior such as spawning at rotating points or stepping through phases.

The C++ equivalent

Keep an int32 GateIndex = 0; member in the header. On each call, switch (GateIndex++ % 3) selects the next branch and advances the counter in one step. Case 0 calls OutputA(), case 1 calls OutputB(), case 2 calls OutputC(), and the modulo keeps the index wrapping so the cycle repeats, matching MultiGate with looping turned on.

Common mistakes

The post-increment GateIndex++ returns the current value before adding one, which is what makes case 0 run first; using pre-increment ++GateIndex would skip OutputA on the first call. Match the modulo (% 3 here) to the number of cases, otherwise an index can fall through to no branch.

Frequently asked questions

How do I make a MultiGate in Unreal C++?+

Store an int32 GateIndex, then switch (GateIndex++ % N) and call a different function in each case. The modulo wraps the index so outputs cycle like a looping MultiGate.

How do I stop a MultiGate from looping in C++?+

Drop the modulo and instead guard the switch so it only runs while GateIndex is below the number of outputs, leaving it inert once every output has fired.

Related Flow Control nodes

View all Flow Control nodes →