How to inherit a boolean
I'm trying to inherit a bool from one script to another so I can use it in a function. Anyone know how to do this
Answer by gjf · Sep 21, 2016 at 05:01 PM
one does not inherit from another script - a reference to the other script is required. typically this is done using GetComponent
. something like:
var otherScript = otherGameObject.GetComponent<OtherScript>();
where otherGameObject
is the other game object and OtherScript
is the name of the script in question.
to access the bool
, one simply does something like this:
otherScript.yourBool = false;
where yourBool
is the bool
in question. don't forget to make it public
.
Unless he meant inheriting it from base script to the derived one
Answer by dimitriosb · Sep 23, 2016 at 04:59 PM
You are not describing well what you are trying to achieve, and this won't likely get you a proper reply that solves your problem.
It is almost certain that you don't want to inherit anything. Inheritance is a very specific term, meaning something completely different than what you seem to express here. You probably want to query the property of one object inside another object, but it's unclear what you really mean.
Please be more specific, explaining exactly what you want to do, so that we can help you.