Shared variable conditionals

LateNighterDK

New member
Hi

Completely new to Behavior Designer and struggling to find my way around all the different tasks.

In general I am missing documentation and example trees showcasing usage of all the tasks. The documentation pages are pretty basic and the 5 example scenes only illustrate the most basic tasks.

ATM I am scratching my head trying to find a simple conditional task that lets me examine a shared variable.
E.g. something like "Shared Bool comparison" or "Shared Float comparison" allowing me to specify when to return Success or Failure based on the value of a Shared variable. Surely such tasks must exist?
 
Hi, you're looking for the BoolComparison and FloatComparison tasks, take a look at the attached screenshot, the asset comes with a dozen of comparison tasks for SharedVariables, which you can naturally use as examples if you need to create custom tasks to compare your own kinds of variables.

If you need help getting started I can offer you a screenshare for free, DM me if you're interested :)
 

Attachments

  • Comparison Tasks.png
    Comparison Tasks.png
    369.3 KB · Views: 7
Thanks a lot Cheo

Your reply made me search more for it, and I eventually located the "Bool comparison" under Conditionals - Unity - Math.
I also found a "Compare shared Bool" under Conditionals - Unity - Shared Variable.

They do the exact same thing even though they are implemented in slightly different ways:

C#:
    public class CompareSharedBool : Conditional
    {
        [Tooltip("The first variable to compare")]
        public SharedBool variable;
        [Tooltip("The variable to compare to")]
        public SharedBool compareTo;

        public override TaskStatus OnUpdate()
        {
            return variable.Value.Equals(compareTo.Value) ? TaskStatus.Success : TaskStatus.Failure;
        }

Versus

C#:
public class BoolComparison : Conditional
{
    [Tooltip("The first bool")]
    public SharedBool bool1;
    [Tooltip("The second bool")]
    public SharedBool bool2;

    public override TaskStatus OnUpdate()
    {
        return bool1.Value == bool2.Value ? TaskStatus.Success : TaskStatus.Failure;
    }

Anyway - Thanks for the help - starting to find my way round the tool :-)
 
Back
Top