SharedVariable cannot be accessed during runtime

ToyHunter

New member
I have created a SharedVariable which cannot be accessed in runtime. My sample codes are as below:

1.
SharedVariable var = behaviorTree.GetVariable("target");
var.SetValue(gameObject);
2.
behaviorTree.SetVariable("target", (SharedGameObject)gameObject);
3.
behaviorTree.SetVariableValue("target", (SharedGameObject)gameObject);

All three of them are unsuccessful, please advise thanks.
 
You should use the Value property to set your variable:

Code:
sharedVariable.Value = gameObject;
 
You should use the Value property to set your variable:

Code:
sharedVariable.Value = gameObject;
Thanks Justin

I resolved by adding below code in Start():
behaviorTree = GetComponent<BehaviorTree>();

Thanks again, Justin. Problem solved.
 
Last edited:
Top