BT Variables do not save data

Ramarolo

Member
Hi, I have a problem that does not allow me to iterate with the proper flow: some variables created in the BT Inspector are never saved, and I have to manually introduce their value every time I stop Runtime. Photo
1672223377818.png
I have to click their right arrow every single time I exit from Runtime to introduce their values. They all refer to a component of an object in the Scene. How can I save their values forever?
Thanks

*I add that Reset Values On Restart is disabled in the Behavior Tree component of the character. Photo
1672225375715.png
 
Last edited:
External trees are not able to save scene references since they are stored in the project and not the scene. This page explains more:

 
Thanks for the quick response!
The link of referencing scene objects is very clear. Between the two solutions exposed, I chose the custom script in the character who needs the references of others, as I think it has a better performance calling it once, instead of Find node in each tree iteration.
I shared my script with the 3 references to help future others needing it:

using UnityEngine;
using BehaviorDesigner.Runtime;

public class Reference : MonoBehaviour
{
GameObject player;
Transform playerTransform;
Vector3 playerPosition;

public void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
playerTransform = player.transform;
playerPosition = transform.position;
var behaviorTree = GetComponent<BehaviorTree>();

behaviorTree.SetVariableValue("Target", player);
behaviorTree.SetVariableValue("TargetTransform", playerTransform);
behaviorTree.SetVariableValue("TargetPosition", playerPosition);
}
}
 
Top