I have what I think should be a simple problem, inside of a parent object I have another object, on that child object I have a java(or unity) script which sets a boolean value (Sighted) to true or false depending on a raycast hit. The child script is named SightDetection. That end of it works fine and the value changes succesfully, however I need to access this true/false variable from the parent object. I have read the docs page, watched many tutorials and looked over previous answers but can not seem to find the right way to access the child scripts variable state. Also it cant be a static variable for obvious reasons.
This is as far as I have gotten, inside the parent script the update runs as such:
function Update()
{
{
if(playonce)
{
agent = GetComponent(NavMeshAgent);
animation.Play("Idle");
playonce = false;
}
}
{
{
if (transform.Find("Armature/Root/Bone_001/MidSpine/Bone_003/Head/Icosphere_002/Headholder/SightMachine").GetComponent(SightDetection).Sighted == true);
{
Visible = true;
print("visible");
}
}
}
}
Please ignore the agent and animation commands following the Update, I’m sorry but I can not get that portion to show up right in this text box. As is the parent script returns finding the child script, but not the variable itself and always returns as true.