Forums › 💬 NodeCanvas › ⚙️ Support › Custom Branch node generates an error. › Reply To: Custom Branch node generates an error.
Hello again 🙂
Here is the updated Branch code to solve this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
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; } condition.Enable(graphAgent, graphBlackboard); var i = condition.Check(graphAgent, graphBlackboard) ? 0 : 1; ( outConnections[i] as FSMConnection ).PerformTransition(); condition.Disable(); } //////////////////////////////////////// ///////////GUI AND EDITOR STUFF///////// //////////////////////////////////////// #if UNITY_EDITOR public override string GetConnectionInfo(int i) { return i == 0 ? "TRUE" : "FALSE"; } #endif } } |
Best regards.