add
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Hivemind {
|
||||
|
||||
[AddComponentMenu("Miscellaneous/Behavior Tree Agent")]
|
||||
public class BehaviorTreeAgent : MonoBehaviour {
|
||||
public BTAsset btAsset;
|
||||
[HideInInspector]
|
||||
public BehaviorTree behaviorTree;
|
||||
public bool debugMode = true;
|
||||
public Context context;
|
||||
|
||||
public void Awake() {
|
||||
behaviorTree = btAsset.Deserialize();
|
||||
context = new Context();
|
||||
}
|
||||
|
||||
public void Start() {
|
||||
if (btAsset == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
Tick();
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
if (behaviorTree == null) {
|
||||
throw new MissingReferenceException("Behavior Tree not defined");
|
||||
}
|
||||
|
||||
behaviorTree.Tick (gameObject, context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user