NullReferenceException on Dynamic Variable in basic tree

lukeiy

New member
I'm getting errors trying to store the result of a FindObjectWithTag into a dynamic variable.

The error is:
NullReferenceException: Object reference not set to an instance of an object BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject.FindGameObjectsWithTag.OnUpdate () (at Assets/Behavior Designer/Runtime/Tasks/Unity/GameObject/FindGameObjectsWithTag.cs:19

Image


I'm pretty sure I've followed the docs here: https://opsive.com/support/documentation/behavior-designer/variables/dynamic-variables/
I changed the Store Value to Dynamic, gave it a name and that should be it no?
 
This looks like an issue with dynamic variables and SharedGameObject lists. If you use a non-dynamic variable it'll work but I will get it fixed for the next update. I can send you a build as soon as I fix it.
 
I just looked into this and you can fix this error by initializing the list within the constructor of the SharedGameObjectList:

Code:
    public class SharedGameObjectList : SharedVariable<List<GameObject>>
    {
        public SharedGameObjectList()
        {
            mValue = new List<GameObject>();
        }

        public static implicit operator SharedGameObjectList(List<GameObject> value) { return new SharedGameObjectList { mValue = value }; }
    }
 
Top