The Basic Mind is where behavior trees are executed. Aside from simply assigning the behavior tree you want to use, this is also where you can assign additional bindings used by the Tree Binding node.
The main reason for accessing the Basic Mind through code would be to change out behavior trees at runtime. This is useful if you are constructing AI at runtime with a custom spawner.
using RAIN.BehaviorTrees; using RAIN.Core; using RAIN.Minds; using System.Collections.Generic; using UnityEngine; public class JesterSpawner : MonoBehaviour { [SerializeField] private GameObject _jesterPrefab = null; [SerializeField] private List<BTAsset> _behaviorAssets = new List<BTAsset>(); private Stack<GameObject> _premadeJesters = new Stack<GameObject>(); void Start() { // Make a some jesters for (int i = 0; i < 10; i++) { // Hide him and make him inactive GameObject tJester = (GameObject)Object.Instantiate(_jesterPrefab); if (_behaviorAssets.Count > 0) { // Set a random tree, and for the sake of a shorter example the bindings are empty AIRig tAIRig = tJester.GetComponentInChildren<AIRig>(); ((BasicMind)tAIRig.AI.Mind).SetBehavior(_behaviorAssets[_behaviorAssets.Count - 1], new List<BTAssetBinding>()); } tJester.hideFlags = HideFlags.HideInHierarchy; tJester.SetActive(false); _premadeJesters.Push(tJester); } } public void SpawnJester(Vector3 aPosition, Quaternion aRotation) { // Setup our jester GameObject tOneJester = _premadeJesters.Pop(); tOneJester.transform.position = aPosition; tOneJester.transform.rotation = aRotation; tOneJester.hideFlags = HideFlags.None; tOneJester.SetActive(true); } }