Hello and good day!
Currently, I’m a bit stuck. I need a non-static instance of a script attached to a parent object that I can then access via another script in a child of that same parent.
Right now, this is what I have.
public cubeAI Instance;
void Awake ()
{
Instance = this;
}
This is in the parent script.
public cubeAI cubeInstance;
void awake()
{
cubeInstance = gameObject.GetComponent<cubeAI>();
}
This is in the child script.
And to say the least, it’s not quite working. I keep getting a null reference. Could anyone enlighten me on what I’m doing wrong? I can get this working by dragging and dropping in the parent into the instance in the inspector of the child during run-time, but this is obviously not a solution I’ll consider.
By the way, this parent and its children are being instantiated at run-time through some code, they’re not present when everything first loads up. I don’t know if that’s helpful at all, but I figured I would mention it regardless.
Thanks for your time, and have a great day!
-Hypocrita_20XX