How can I realize a nasty nested if-else jumble like the one below in blueprint in the most compact way?
update: I need to do the overall thing in a blueprint but I’d prefer a solution that implements the nested if-else in a C++ code that I can use in the blueprint. The problem is I don’t know how to use C++ codes or macros in blueprint.
if (x < val1a)
{
if (y < val2a)
{
z = a1
}
else if (y < val2b)
{
z = a2
}
else if (y < val2c)
{
z = a3
}
}
else if (x < val1b)
{
if (y < val2a)
{
z = b1
}
else if (y < val2b)
{
z = b2
}
else if (y < val2c)
{
z = b3
}
}
else if (x < val1c)
{
if (y < val3a)
{
z = c1
}
else if (y < val3b)
{
z = c2
}
else if (y < val3c)
{
z = c3
}
}
no i meant how to realize it when I wrote “realize”. blueprint visuals would really help. it is not a homework. just something i need to do without it getting out of hand. there is no way to formulize this. all need to be realized in the same function/blueprint. x is camera distance and y is gaze distance. the actual if-else thing is much larger so i need a smart solution that is compact. not sure if your intent was pure trolling but thanks anyway
there is no if-else system implemented in blueprints.
what you can do is:
pavk the whole branch-in-branch-in-branch…etc thing into a macro, that has multiple return execs
that macro is much smaller (compacter) in the actual graphs, but bigger when editing it
Just to be sure… are all the variables correct?
For the x has val1a, val1b, val1c to compare.
But for the y, same (val2a,val2b,val2c) is used for first 2 groups and (val3a,val3b, val3c) is used for the last group.
And I’m curious: what is the application scenario for this if-else logic?
Would be helpful to know if he’s looking to do this with existing Blueprint nodes…
Of if he’s looking to do it by creating C++ code within a custom Blueprint function node??
Reading through this thread a few times I’m still not sure which way of these he wants to go…
Compact? Written in C++ and called as a blueprint callable function. Or, tucked into a macro, function or a collapsed graph.
But just on a single graph? A bunch of select nodes, which either return the value if the condition is met, or return the value given by another select node which does the same, until you are at the final condition within the bracket at which you will either return the result given by the last condition, or if that fails, z.
Just to be sure… are all the variables correct?
For the x has val1a, val1b, val1c to compare.
But for the y, same (val2a,val2b,val2c) is used for first 2 groups and (val3a,val3b, val3c) is used for the last group.
yes unfortunately they are different for different thresholds of x
And I’m curious: what is the application scenario for this if-else logic?
I need to place different versions of the same mesh according to its distance from camera and gaze location. Actually that is another challenge I need to find a solution
Would be helpful to know if he’s looking to do this with existing Blueprint nodes…
Of if he’s looking to do it by creating C++ code within a custom Blueprint function node??
Reading through this thread a few times I’m still not sure which way of these he wants to go…
I need to use a blueprint but I wouldn’t mind realizing this nested if-else with a C++ code that I can use in the blueprint. The problem is I’ve never done this so I’d appreciate a solution like that or at least pointers to resources telling how to do that
Oh god for the 2nd time, no this is not a homework. Is every question here interrogated whether it is homework now? Why bother with questions then? No this is actually part of my research. So a neat solution would not be helping something unethical but on the contrary it’d be helping scientific research