Edit bool on another script and object.
I have been looking for a specific answer for this question, while I have found some similiar nothing for this specific thing. Or at least nothing similiar enough to work.... or I am not looking for the right question.
ObjectA instantiates ObjectB which has its own script (ScriptB) and has the tag TagB (If needed)
I need to change a bool within ObjectB's script from the script on ObjectA (ScriptA).
I know that I do not have much to go on, or to give you to go on, but I really have no idea where to go with this (Have tried way to many things already).
public class blockProperties : MonoBehaviour {
public bool timer;
scriptB ScriptB;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
timer += Time.deltaTime;
if (timer >= 5f){
ScriptB.freezeY = false;
}
}
}
ObjectB's script
public class scriptB : MonoBehaviour {
public bool freezeY = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (freezeY == false)
{
GetComponent<Rigidbody>().constraints &= ~RigidbodyConstraints.FreezePositionY;
}
}
}
Answer by BlackSnow_2 · Sep 01, 2015 at 05:01 AM
Calling from another script is like this:
Public [ScriptName] [Variable];
Void Start () { [Variable].AmIAmazing = true; }
If you need me to write your code just ask, I'm just in a bit of a rush at the moment.
Your answer
Follow this Question
Related Questions
How to get a public int equal the same number when added in all object that have the same script? 1 Answer
2 same Scripts w/ GetComponent : one works, one doesn't 2 Answers
Unity GetComponent Script? 1 Answer
GetComponent returning null with no errors 1 Answer
questions about instantiate copies 0 Answers