Reply To: Error: Condition.Check when enabled = false

Forums 💬 NodeCanvas ⚙️ Support Error: Condition.Check when enabled = false Reply To: Error: Condition.Check when enabled = false

#16240
nodeshelp
Participant

    Thank you for the quick response! This is actually a node that you kindly provided in response to my question awhile ago. Here is the code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using NodeCanvas.Framework;

    namespace NodeCanvas.StateMachines
    {

    public class Branch : FSMState, ITaskAssignable<ConditionTask>
    {

    [SerializeField]
    private ConditionTask _condition;

    private ConditionTask condition
    {
    get { return _condition; }
    set { _condition = value; }
    }

    Task ITaskAssignable.task
    {
    get { return condition; }
    set { condition = (ConditionTask)value; }
    }

    public override bool allowAsPrime { get { return false; } }
    public override int maxInConnections { get { return -1; } }
    public override int maxOutConnections { get { return 2; } }

    protected override void OnEnter()
    {
    if (condition == null)
    {
    Finish(false);
    return;
    }

    var i = condition.CheckCondition(graphAgent, graphBlackboard) ? 0 : 1;
    (outConnections[i] as FSMConnection).PerformTransition();
    Finish(i == 0);
    }

    ////////////////////////////////////////
    ///////////GUI AND EDITOR STUFF/////////
    ////////////////////////////////////////
    #if UNITY_EDITOR

    public override string GetConnectionInfo(int i)
    {
    return i == 0 ? “TRUE” : “FALSE”;
    }

    #endif

    }

    }