I have a problem to update variable value after the first setup.
Custom variable
The first time the code runs the variable is added, but the second time the variable is not updated and stays with his first value.
Whatever what I try, this variable is not updated. And I'm sure the variable is good because the name of the behavior is well setted.
Custom variable
C#:
namespace HMH.BehaviorDesigner
{
[System.Serializable]
public class SharedEntity : SharedVariable<Entity>
{
public static implicit operator SharedEntity(Entity value)
{
return new SharedEntity { mValue = value };
}
public static implicit operator Entity(SharedEntity value)
{
return value.mValue;
}
}
}
The first time the code runs the variable is added, but the second time the variable is not updated and stays with his first value.
Whatever what I try, this variable is not updated. And I'm sure the variable is good because the name of the behavior is well setted.
C#:
var btComponent = new BehaviorTreeComponent
{
BehaviorTreeSocle = _behaviorTreeFreeList.RemoveLast(),
ExternalBehaviorTree = dataManager.GetBehaviorTree(spawnAgentInit.BehaviorTreeType),
BehaviorTreeId = spawnAgentInit.BehaviorTreeType
};
btComponent.BehaviorTreeSocle.BehaviorName = "Agent " + entity;
btComponent.BehaviorTreeSocle.ExternalBehavior = btComponent.ExternalBehaviorTree;
var test=(SharedVariable)btComponent.BehaviorTreeSocle.GetVariable("AgentEntity");
test.SetValue(entity);
//test 2 not working either
//btComponent.BehaviorTreeSocle.SetVariable("AgentEntity",test);
//test 3 not working either
//btComponent.BehaviorTreeSocle.SetVariableValue("AgentEntity", (SharedEntity)entity);
btComponent.BehaviorTreeSocle.enabled = true;
btComponent.BehaviorTreeSocle.EnableBehavior();
Last edited: