Skip to content

Commit ac096f8

Browse files
committed
More documentation
1 parent 3a16418 commit ac096f8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

BehaviourGraph/BehaviourGraph.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public class BehaviourGraph : NodeGraph, ISerializationCallbackReceiver
1818
[SerializeField]
1919
internal BaseNode root = null;
2020

21+
/// <summary>
22+
/// Generates an executable behaviour tree from this behaviour graph.
23+
/// </summary>
24+
/// <param name="executingOn">Which object to create the tree for</param>
25+
/// <returns>A behaviour tree for the input game object.</returns>
2126
public BehaviourTree.BehaviourTree GenerateBehaviourTree(GameObject executingOn)
2227
{
2328
var cloneTree = new BehaviourTree.BehaviourTree(executingOn);

BehaviourTree/BehaviourTree.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class BehaviourTree
1212
internal GameObject owner;
1313
private TreeBaseNode root;
1414
internal ContextWalker contextWalker;
15-
15+
1616
public BehaviourTree(GameObject owner)
1717
{
1818
this.owner = owner;
@@ -26,6 +26,9 @@ internal void RuntimeSetup(TreeBaseNode newRoot, GameObject owningObject)
2626
contextWalker.SetContextPointer(newRoot.context);
2727
}
2828

29+
/// <summary>
30+
/// Performs an evaluation of the behaviour tree.
31+
/// </summary>
2932
public void Evaluate()
3033
{
3134
ExecuteTree();

Examples/ThingyController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ public class ThingyController : MonoBehaviour
3333
private float chaseRadius = 150;
3434

3535
private float currentRadius;
36-
WaitForEndOfFrame cachedWait = new WaitForEndOfFrame();
3736

3837
private void Awake()
3938
{
39+
/*This is the only important line of code*/
4040
tree = graph.GenerateBehaviourTree(gameObject);
41+
4142
speed = Random.Range(.5f*speed, 1.5f*speed);
4243
chaseSpeed = Random.Range(.5f*chaseSpeed, 1.5f*chaseSpeed);
4344

@@ -49,6 +50,7 @@ private void Awake()
4950

5051
public void Update()
5152
{
53+
/*This one is slightly important as well... It runs the tree code. Sorta important.*/
5254
tree.Evaluate();
5355
}
5456

0 commit comments

Comments
 (0)