public CandiceBehaviorNode CreateBehaviorTree(CandiceAIController agent) { Initialise(); rootNode = null; CandiceBehaviorNodeS _rootNode = null; nodes = behaviorTree.GetNodes(); _rootNode = nodes[0]; Debug.LogError("Agent: " + agent.AgentID); switch (_rootNode.type) { case CandiceAIManager.NODE_TYPE_SELECTOR: rootNode = new CandiceBehaviorSelector(); rootNode.id = _rootNode.id; rootNode.Initialise(agent.transform, agent); (rootNode as CandiceBehaviorSelector).SetNodes(GetChildren(behaviorTree, _rootNode)); break; case CandiceAIManager.NODE_TYPE_SEQUENCE: rootNode = new CandiceBehaviorSequence(); rootNode.id = _rootNode.id; rootNode.Initialise(agent.transform, agent); (rootNode as CandiceBehaviorSequence).SetNodes(GetChildren(behaviorTree, _rootNode)); break; } return(rootNode); }