Patrol waypoints disappear after changing scene

fpaciello99

New member
Hi, I'm trying to implement a simple partrol solution with behaviour tree.
I have a problem, all my waypoints references in patrol inspector, are getting null when I change scene from menu to game.
Any tips?
 

fpaciello99

New member
I created this SharedVariable, but how can i set them up in the patrol variable?


C#:
using UnityEngine;
using BehaviorDesigner.Runtime;

[System.Serializable]
public class ryWaypoints
{
    public GameObject[] Waypoints;
}

[System.Serializable]
public class MilitaryWaypoints : SharedVariable<ryWaypoints>
{
    public override string ToString() { return mValue == null ? "null" : mValue.ToString(); }
    public static implicit operator MilitaryWaypoints(ryWaypoints value) { return new MilitaryWaypoints { mValue = value }; }
}

BehavProb.PNG
 
Last edited:

Justin

Administrator
Staff member
You do not need to create a new SharedVariable Type. The Patrol task already has a SharedGameObjectList so you just need to set that list. You can do so outside of the behavior tree:


Instead of setting the Value to 42 in this example you'd set the waypoints.

Code:
myVariable.Value.Add(waypoint);
 
Top