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.
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…
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.
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.