Forums › 💬 NodeCanvas › 🗨️ General Discussion › [Feature Request] Condition blocks / Nested conditions
I love how FSM graphs can be set up in general (I use only FSM’s right now). But for me there’s a significant problem when transitions become somewhat complex.
Let me demonstrate. I believe, currently there’s no way to put a condition like this:
a && b || c
into a single transition. It’s either all condition tasks with “OR”, or all condition tasks with “AND”. Now imagine it becomes something like this, and it often does in my workflow:
a && b && && c && (d || e || f)
It seems the only way to implement this right now is to, firstly, split it into three blocks, like that:
1. a && b && c && d
2. a && b && c && e
3. a && b && c && f
And then, I have the following workarounds at my disposal:
– if the origin is an “Any State” node, make 3 of those and assign them conditions 1, 2 and 3 correspondingly;
– if the origin is a normal state, make 3 copies of the target node with all the consequences (copying other transitions going from that state, etc);
Both of those involve lots of duplicate logic which multiplies modification time, and is prone to bugs.
Now with the addition of PASS nodes, as they don’t even use up a frame, composite “conditions” can indeed be constructed, like this:
[attachment file=”1348.png”]
But I believe PASS nodes were not intended for this use case, causing unnecessary clutter, and in an FSM graph these constructions look like lower level code where it doesn’t belong.
And even if I try to utilize them here, PASS nodes cause another problem: as they are still states, when they start, the previous state has its actions stopped (and their OnStop() methods will get called, which I use extensively). So whatever was being executed in the source node will often get interrupted even if the overall “condition” doesn’t succeed. I also tried the experimental stacked calls, which are interesting but do not really help here.
So this is what I’m suggesting, as an idea how it might look. Hope it’s clear by itself:
[attachment file=”nc-nested-conditions.png”]
I think I can help with the implementation, if you wish.
Thanks.
Hello there,
Some time ago (meaning some version back), there was actually the ability to add Condition Lists within other Condition Lists and as such be possible to create such combinations you are after. However, this ability was removed in favor of streamlining the workflow (as well as UI) and none really missed it (until now I guess 🙂 ). I will take another look at it at the possibility of implementing it in a streamlined fashion (once again, mostly UI wise), but I can’ really promise anything right now. Have you considered replacing the variables you are checking with custom Condition Tasks that are tailored to your game and would basically self-contain the required checks within? Or even combining those variables into more singular ones?
For example, the “ButtonPressed && SufficientMana && Grounded”, could probably be combined together in a “CanCast” variable/condition? Just an idea that may help.
Let me know!
Thanks 🙂
Hi!
As far as streamlining goes, I think it can’t hurt to just have an option for those who might want more control.
[quote quote=14883]Have you considered replacing the variables you are checking with custom Condition Tasks that are tailored to your game and would basically self-contain the required checks within? Or even combining those variables into more singular ones?[/quote]
This is exactly what I’m trying to avoid: doesn’t it lead to the opposite direction of what the whole NC system is designed to be? I.e. making multi-purpose, flexible tasks and combining them into visually clear structures.
Anyways, thanks for consideration!
I second this request!
On occasion I’ve had to make intermediary states to break up some condition checks because I don’t want to roll them all up into a custom ConditionTask not because I can’t, but because it wouldn’t make much sense (would only be used in that single scenario, and I might even throw that state machine away in a few hours/days).
