I am trying to change a boolean variable that is in ScriptA with ScriptB. Here is a small example:
public class ScriptA : MonoBehaviour {
public bool followBall;
void Update() {
if(followBall)
Make camera follow ball;
}
}
public class ScriptB : MonoBehaviour {
public ScriptA a;
void Update() {
if(space is pressed) {
create object to follow;
a.followBall = true;
}
}
}
When I try to change the boolean variable in scriptA with scriptB it stays false. I made sure that I dragged the ScriptA component onto ScriptB. I don’t know what I am doing wrong?