Pietrofonix
New member
Hi guys, I need help with the Shared Variables. I created a Global Variable of type GameObject in a Behaviour Tree called "AudioObjectDetected" and I want to assign it to a SharedGameObject variable that I created inside a Node.
In the example above I'm trying to access to the AC.Hotspot component by using "runtimeFaceObject.Value.GetComponent", but Unity gives me the error "Object reference not set to an instance of an object". If I use the normal type GameObject It works perfectly. Do you know why SharedVariables can't access components with Value.GetComponent?
public class BDFaceObject : Action
{
public SharedGameObject runtimeFaceObject;
public override void OnStart()
{
runtimeFaceObject = (SharedGameObject)GlobalVariables.Instance.GetVariable("AudioObjectDetected");
base.OnStart();
}
public override TaskStatus OnUpdate()
{
AC.Hotspot faceObjectHotspot = runtimeFaceObject.Value.GetComponent<AC.Hotspot>();
}
}
In the example above I'm trying to access to the AC.Hotspot component by using "runtimeFaceObject.Value.GetComponent", but Unity gives me the error "Object reference not set to an instance of an object". If I use the normal type GameObject It works perfectly. Do you know why SharedVariables can't access components with Value.GetComponent?
Last edited: