public override NodeStatus Tick(BehaviorBlackboard data) { GameObject[] objects = GameObject.FindGameObjectsWithTag(selectedTag); Transform agent; Transform closest; float minDist; if (objects.Length == 0) { return(NodeStatus.FAILURE); } agent = (Transform)data.Get("_BTD_Agent"); minDist = Vector3.Distance(agent.position, objects[0].transform.position); closest = objects[0].transform; for (int i = 1; i < objects.Length; i++) { float distance = Vector3.Distance(agent.position, objects[i].transform.position); if (distance < minDist) { minDist = distance; closest = objects[i].transform; } } data.Add(entry, closest); return(NodeStatus.SUCCESS); }
public override NodeStatus Tick(BehaviorBlackboard data) { Transform agent = (Transform)data.Get("_BTD_Agent"); Transform child = agent.Find(childName); if (child != null) { ColliderHelper colHelper = child.GetComponent <ColliderHelper>(); if (colHelper != null) { if (colHelper.trigger != null) { data.Add(entry, colHelper.trigger); return(NodeStatus.SUCCESS); } else { return(NodeStatus.FAILURE); } } else { Debug.LogError("Behavor Tree Designer\nNo ColliderHelper script found on child: " + childName + " on object: " + agent.name); return(NodeStatus.ERROR); } } else { Debug.LogError("Behavor Tree Designer\nChild: " + childName + " not found on object: " + agent.name); return(NodeStatus.ERROR); } }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; if (start) { data.Add(guid.ToString(), Time.time); } float time = (float)data.Get(guid.ToString()); if (time + waitTime > Time.time) { start = false; return(NodeStatus.RUNNING); } else { start = true; return(node.Tick(data)); } }
public override NodeStatus Tick(BehaviorBlackboard data) { List <NodeOutput> nodes = this.Outputs; BaseBehaviorNode[] nodeArray = new BaseBehaviorNode[3]; int count = 0; foreach (NodeOutput node in nodes) { if (node.connections.Count == 0) { continue; } nodeArray[count] = (BaseBehaviorNode)(node.connections[0].body); count++; } if (count == 0) { Debug.LogError("Behavor Tree Designer\nNo output node is connected on node: " + this.name); return(NodeStatus.ERROR); } int rand = UnityEngine.Random.Range(0, count); NodeStatus childstatus = nodeArray[rand].Tick(data); return(childstatus); }
public override NodeStatus Tick(BehaviorBlackboard data) { Transform player = (Transform)data.Get("_BTD_Agent"); Transform target = ((Transform)data.Get(entry)); NavMeshAgent agent = player.GetComponent <NavMeshAgent>(); Vector3 playerPos = player.position; if (agent == null) { Debug.LogError("Behavor Tree Designer\nNo NavMeshAgent component found on node: " + this.name); return(NodeStatus.ERROR); } if (target == null) { return(NodeStatus.ERROR); } Vector3 targetPos = target.position; agent.stoppingDistance = stopDist; agent.destination = targetPos; if (Vector3.Distance(targetPos, playerPos) < stopDist) { return(NodeStatus.SUCCESS); } else if (agent.hasPath) { return(NodeStatus.RUNNING); } else { return(NodeStatus.FAILURE); } }
public override NodeStatus Tick(BehaviorBlackboard data) { List <NodeOutput> nodes = this.Outputs; int count = 0; foreach (NodeOutput node in nodes) { if (node.connections.Count == 0) { continue; } NodeStatus childstatus = ((BaseBehaviorNode)(node.connections[0].body)).Tick(data); count++; if (childstatus != NodeStatus.SUCCESS) { return(childstatus); } } if (count == 0) { Debug.LogError("Behavor Tree Designer\nNo output node is connected on node: " + this.name); return(NodeStatus.ERROR); } return(NodeStatus.SUCCESS); }
public override NodeStatus Tick(BehaviorBlackboard data) { switch (entType) { case EntryType.BOOL: data.Add(entry, boolEntry); break; case EntryType.INTEGER: data.Add(entry, intEntry); break; case EntryType.FLOAT: data.Add(entry, floatEntry); break; case EntryType.CLASS: data.Add(entry, null); break; default: return(NodeStatus.ERROR); } return(NodeStatus.SUCCESS); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; NodeStatus status = NodeStatus.SUCCESS; int rep = (int)data.Get(guid.ToString()); status = node.Tick(data); if (status == NodeStatus.RUNNING) { return(status); } rep += 1; if (rep < repNumber) { status = NodeStatus.RUNNING; data.Add(guid.ToString(), rep); } else { data.Add(guid.ToString(), 0); } return(status); }
public override void Init(BehaviorBlackboard data) { base.Init(data); if (subTree == null) { Debug.LogError("Behavor Tree Designer\nNo subtree assigned!"); return; } subRoot = subTree.GetRootNode(); subRoot.Init(data); }
public override NodeStatus Tick(BehaviorBlackboard data) { List <NodeOutput> nodes = this.Outputs; NodeStatus[] childstatus = new NodeStatus[nodes.Count]; int count = 0; bool running = false; bool fail = false; for (int i = 0; i < nodes.Count; i++) { if (nodes[i].connections.Count == 0) { continue; } count++; childstatus[i] = ((BaseBehaviorNode)(nodes[i].connections[0].body)).Tick(data); } if (count == 0) { Debug.LogError("Behavor Tree Designer\nNo output node is connected on node: " + this.name); return(NodeStatus.ERROR); } foreach (NodeStatus status in childstatus) { if (status == NodeStatus.ERROR) { return(NodeStatus.ERROR); } if (status == NodeStatus.RUNNING) { running = true; } if (status == NodeStatus.FAILURE) { fail = true; } } if (running) { return(NodeStatus.RUNNING); } else if (fail) { return(NodeStatus.FAILURE); } else { return(NodeStatus.RUNNING); } }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nRoot node is not connected."); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; return(node.Tick(data)); }
public override NodeStatus Tick(BehaviorBlackboard data) { int index = (int)data.Get("_BTD_WaypointIndex"); waypointParent = (Transform)data.Get("_BTD_Waypoint"); if (waypointParent == null) { return(NodeStatus.FAILURE); } Waypoints waypoints = waypointParent.GetComponent <Waypoints>(); if (!waypoints.circular && index == waypointParent.childCount - 1) { backwards = true; } if (!waypoints.circular && index == 0) { backwards = false; } if (backwards) { index--; } else { index++; } if (index >= waypointParent.childCount) { index = 0; } if (index < 0) { index = waypointParent.childCount - 1; } Transform target = waypointParent.GetChild(index); data.Add(entry, target); data.Add("_BTD_WaypointIndex", index); if (target == null) { return(NodeStatus.FAILURE); } return(NodeStatus.SUCCESS); }
public virtual void Init(BehaviorBlackboard data) { List <NodeOutput> nodes = this.Outputs; foreach (NodeOutput node in nodes) { if (node.connections.Count == 0) { continue; } ((BaseBehaviorNode)(node.connections[0].body)).Init(data); } guid = Guid.NewGuid(); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; NodeStatus status = node.Tick(data); Debug.Log("Behavor Tree Designer Logger\nComing from: " + node.name + ". Result: " + status.ToString()); return(status); }
private void Awake() { if (behaviorTree == null) { Debug.LogError("Behavor Tree Designer\nNo behavior assigned!"); return; } if (agent == null) { Debug.LogError("Behavor Tree Designer\nNo agent assigned!"); return; } data = new BehaviorBlackboard(); data.Add("_BTD_Agent", agent); rootNode = behaviorTree.GetRootNode(); }
public override NodeStatus Tick(BehaviorBlackboard data) { object classObj; if (global) { classObj = data.GetGlobal(entry); } else { classObj = data.Get(entry); } if (classObj == null) { classObj = "null"; } Debug.Log("Behavor Tree Designer Logger\nEntry: " + classObj); return(NodeStatus.SUCCESS); }
private void Start() { if (behaviorTree == null) { Debug.LogError("Behavor Tree Designer\nNo behavior assigned!"); return; } if (agent == null) { Debug.LogError("Behavor Tree Designer\nNo agent assigned!"); return; } data = new BehaviorBlackboard(); data.Add("Agent", agent); rootNode = behaviorTree.GetRootNode(); rootNode.Init(data); InvokeRepeating("DoTick", 0, tickTime); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; NodeStatus status = node.Tick(data); if (status == NodeStatus.SUCCESS) { status = NodeStatus.FAILURE; } else if (status == NodeStatus.FAILURE) { status = NodeStatus.SUCCESS; } return(status); }
public override NodeStatus Tick(BehaviorBlackboard data) { NodeStatus retVal = NodeStatus.FAILURE; switch (entType) { case EntryType.BOOL: if (boolEntry == (bool)data.Get(entry)) { retVal = NodeStatus.SUCCESS; } break; case EntryType.INTEGER: if (intEntry == (int)data.Get(entry)) { retVal = NodeStatus.SUCCESS; } break; case EntryType.FLOAT: if (floatEntry == (float)data.Get(entry)) { retVal = NodeStatus.SUCCESS; } break; case EntryType.CLASS: if (data.Get(entry) != null) { retVal = NodeStatus.SUCCESS; } break; default: retVal = NodeStatus.ERROR; break; } return(retVal); }
public override NodeStatus Tick(BehaviorBlackboard data) { GameObject[] objects = (GameObject[])GameObject.FindObjectsOfType(typeof(GameObject)); Transform agent; Transform closest; float minDist; if (objects.Length == 0) { return(NodeStatus.FAILURE); } List <GameObject> layerList = new List <GameObject>(); for (int i = 0; i < objects.Length; i++) { if (objects[i].layer == selectedLayer) { layerList.Add(objects[i]); } } agent = (Transform)data.Get("Agent"); minDist = Vector3.Distance(agent.position, objects[0].transform.position); closest = objects[0].transform; for (int i = 1; i < objects.Length; i++) { float distance = Vector3.Distance(agent.position, objects[i].transform.position); if (distance < minDist) { minDist = distance; closest = objects[i].transform; } } data.Add(entry, closest); return(NodeStatus.SUCCESS); }
// Required function. This is where the actual node logic goes. public override NodeStatus Tick(BehaviorBlackboard data) { return(NodeStatus.SUCCESS); }
public override NodeStatus Tick(BehaviorBlackboard data) { return(nodeStatus); }
public override NodeStatus Tick(BehaviorBlackboard data) { return(subRoot.Tick(data)); }
public override NodeStatus Tick(BehaviorBlackboard data) { anim.SetBool(parameter, enabled); return(NodeStatus.SUCCESS); }
public abstract NodeStatus Tick(BehaviorBlackboard data);
public override NodeStatus Tick(BehaviorBlackboard data) { anim.SetTrigger(parameter); return(NodeStatus.SUCCESS); }
public override void Init(BehaviorBlackboard data) { base.Init(data); data.Add("_BTD_WaypointIndex", -1); }
public override void Init(BehaviorBlackboard data) { base.Init(data); anim = ((Transform)data.Get("_BTD_Agent")).GetComponent <Animator>(); }
public override NodeStatus Tick(BehaviorBlackboard data) { anim.SetFloat(parameter, value); return(NodeStatus.SUCCESS); }
public override void Init(BehaviorBlackboard data) { base.Init(data); data.Add(guid.ToString(), 0.0f); }