# Help with "if, else if, else" blueprint macro

**URL:** <https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236>\
**Category:** Blueprint\
**Tags:** macros, unreal-engine, Blueprint, CPP, question\
**Created:** [May 13, 2014, 4:09pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236 "2014-05-13T16:09:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_04894815](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04894815](https://forums.unrealengine.com/u/anonymous_user_04894815)\
**Post date:** [May 13, 2014, 4:09pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/1 "2014-05-13T16:09:42Z")

</div>

I’m trying to make a blueprint macro that combines multiple branches into an “if, else if, else if, … else” format. Easy enough, but I was hoping to make its length dynamic by having the little “Add pin (+)” option in it much the same way sequence or switch nodes work.

If this requires coding that’s fine. I just want to know if it’s possible, and how to do it. My google-fu has turned up nothing.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_04894815](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04894815](https://forums.unrealengine.com/u/anonymous_user_04894815)\
**Post date:** [May 20, 2014, 3:20pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/2 "2014-05-20T15:20:21Z")

</div>

Bumper cars

---

<div class="post-metadata">

**Author:** ![mortengu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mortengu](https://forums.unrealengine.com/u/mortengu)\
**Post date:** [May 20, 2014, 6:50pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/3 "2014-05-20T18:50:57Z")

</div>

Hi, Have you looked into using the **Switch on Int** node ? It’s a flow node that takes in an integer (you decide how many cases you want by the Add Pin (+) option you requested), and it diverts the program flow to the output flow node that matches your **Int** input… Other switch nodes are also available, and might suit your program better than the int one…

---

<div class="post-metadata">

**Author:** ![Zeustiak](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zeustiak](https://forums.unrealengine.com/u/Zeustiak)\
**Post date:** [May 21, 2014, 8:52am UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/4 "2014-05-21T08:52:33Z")

</div>

Even better, Switch on Enum. 🙂

Also, consider the OR node. It helped me clean up quite a few branches by using them.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_04894815](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04894815](https://forums.unrealengine.com/u/anonymous_user_04894815)\
**Post date:** [May 21, 2014, 1:35pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/5 "2014-05-21T13:35:54Z")

</div>

I’ve used many of these methods and they work fine, but what i’m hoping to achieve is something simple and direct that I can add to the macro library.

The end goal is to make a single macro with as long a chain of branches as desired, starting with 2, and being expanded with the [Add Pin +] button.

If this is impossible to make with the current tools hopefully the UE devs could implement something like this in the future.

Example:

![6719-ifelse2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/8/7/4873f559675a6b0e21367a1038ae7e6d154c4715.png)

---

<div class="post-metadata">

**Author:** ![Zeustiak](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zeustiak](https://forums.unrealengine.com/u/Zeustiak)\
**Post date:** [May 21, 2014, 1:49pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/6 "2014-05-21T13:49:56Z")

</div>

If procedural node creation is possible it is somewhere in C++. I would suggest reposting this question in that answerhub for the best results.

I am curious though, what kind of mechanic are you thinking about that would need such a macro? You could probably emulate the same kind of thing with Arrays. X Happens, then Array element is generated that runs a Switch to Y branches.

Essentially your basic branch setup will reach some fundamental limit of complexity, so that is how big your Enum would be. Then you procedurally generate the Array elements to choose between them. Your array could be an arbitrary length and accomplish the same thing as your proposed Branch idea.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_04894815](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04894815](https://forums.unrealengine.com/u/anonymous_user_04894815)\
**Post date:** [May 21, 2014, 2:37pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/7 "2014-05-21T14:37:17Z")

</div>

You’d use this any time you’d need an if chain. So:

```
if (numChar < minNum)
    { // too few}
else if (numChar < lowNum)
    { // comfortable}
else if (numChar < maxNum)
    { //crowded}
else
    //too many

```

In blueprint, this would require 3 branch nodes. The macro would reduce this to just one. Even just combining two nodes into one would reduce clutter, and that’s exactly what macros are for.

As for using arrays and switches, that’s fine as long as I plan to check the array variables enough times to make the hassle of setting it up worthwhile. I’d also only be able to use that setup in that specific instance. Remember, this would be in a macro library, so any project that has access to that library would be able to use this, pick the number of conditions, plug them in, and be good to go in seconds.

---

<div class="post-metadata">

**Author:** ![Zeustiak](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zeustiak](https://forums.unrealengine.com/u/Zeustiak)\
**Post date:** [May 22, 2014, 4:09am UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/8 "2014-05-22T04:09:49Z")

</div>

Oh I see.

I guess that would almost be like a Switch on Boolean.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_04894815](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_04894815](https://forums.unrealengine.com/u/anonymous_user_04894815)\
**Post date:** [May 22, 2014, 1:11pm UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/9 "2014-05-22T13:11:08Z")

</div>

pretty much

---

<div class="post-metadata">

**Author:** ![Colory\_Games](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Colory\_Games](https://forums.unrealengine.com/u/Colory_Games)\
**Post date:** [September 24, 2022, 2:09am UTC](https://forums.unrealengine.com/t/help-with-if-else-if-else-blueprint-macro/283236/10 "2022-09-24T02:09:08Z")

</div>

Sorry for digging the old post.  
I think the below code plugin meet your requirement.

> **[Advanced Control Flow in Code Plugins - UE Marketplace](https://www.unrealengine.com/marketplace/en-US/product/advanced-control-flow)**
>
> Custom Blueprint nodes to realize the complex control flow
