There are concept of Classes and Objects
Objects are physical instances of classes. The latter you can think of as some sort of “blueprints”, a non-existing set of instructions.
with AeroplaneController.m_Immobilized = true; you just ordered a “blueprint” to execute something. But it can’t - it’s not physically present anywhere, it’s just a blueprint.
You instead need to find objects in the scene which are the incarnations of such a class. These objects are monobehaviors, which are attached to gameObjects, similar to any other component.
You can do it with GameObject.Find() which a fairly expensive function to call, don’t do it every Update.
Alternativelly, you can create a slot, into which you can drag-drop the object. You should declare the slot from inside of your script.
In the script where you want to have access via the slot, write:
public YourBluePrintName yourVariableName;
for example AeroplaneController incarnationOfAeroController;
You can then drag-and-drop this monobehavior “blueprint” onto the gameObject from where you want the code to work. Now, drag-and drop the gameObject which has AeroplaneController script attached to it, into the slot.
Don’t forget to do something with this slot, so it’s not invain. You should do it from inside the script, for example
void Update()
{
if(Input.GetMouseButtonDown(0) == true)
{
incarnationOfAeroController.Immobilize();
}
}
At the current stage, this video is pretty much the best you can find (I’ve scrubbed to the needed time, you will enjoy this lesson like many others)
