smogger914
New member
Super new to behavior trees and trying to figure out how this should work.
I am trying to set a sharedVariable for a tree when I initialize it like this:
I have a simple task that prints out the myFloat variable.
The value that is printed out is always zero, i.e. what is set in the variables tab.
I have also mapped the variable to the Task in the UI.
I feel like I am missing something super simple and it should work.
Any help is greatly appreciated!
I am trying to set a sharedVariable for a tree when I initialize it like this:
C#:
GameObject characterGameObject = new GameObject();
var behaviorTree = characterGameObject.AddComponent<BehaviorTree>();
behaviorTree.ExternalBehavior = characterBehaviorTree;
behaviorTree.SetVariable("myFloat", (SharedFloat)26f);
I have a simple task that prints out the myFloat variable.
C#:
using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
[TaskCategory("Common")]
public class CharacterHasJob : Conditional
{
public SharedFloat myFloat;
public override void OnAwake()
{
Debug.Log("CharacterHasJob myFloat: " + myFloat.ToString());
}
public override TaskStatus OnUpdate()
{
return TaskStatus.Success;
}
}
The value that is printed out is always zero, i.e. what is set in the variables tab.
I have also mapped the variable to the Task in the UI.
I feel like I am missing something super simple and it should work.
Any help is greatly appreciated!