-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgetBoolOnOtherTree.cs
39 lines (32 loc) · 1.04 KB
/
getBoolOnOtherTree.cs
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
using UnityEngine;
using System.Collections;
namespace BehaviorDesigner.Runtime.Tasks.Custom
{
[TaskDescription("Gets a bool var on another tree defined by sharedGameObject")]
public class getBoolOnOtherTree : Action
{
public SharedGameObject sharedGameObject;
public string variableName;
public SharedBool targetVariable;
private BehaviorTree behaviorTree;
public override void OnStart()
{
behaviorTree = sharedGameObject.Value.GetComponent<BehaviorTree>();
}
public override TaskStatus OnUpdate()
{
if (behaviorTree == null)
{
return TaskStatus.Failure;
}
targetVariable.Value = (behaviorTree.GetVariable(variableName) as SharedBool).Value;
return TaskStatus.Success;
}
public override void OnReset()
{
behaviorTree = null;
variableName = "";
targetVariable = false;
}
}
}