so i have two scripts and I want one of the scripts to use a variable on the other script and change it to true.
I have a dialogue system and i have a quest system. I want to be able to press okay and then change the a variable to true on the quest system.
ex : go kill the bat [ you press okay]
(the quest script sees if it has been accepted )
The two basic choices you have are:
Class variables - only appropriate of only one Quest script ever in your world
static var okay = false;
if (...) Quest.okay = true;
Reference between script components:
var okay = false;
var questSystem : Quest;
if (....) questSystem.ok = true;
You then need to ensure `questSystem is set, either in the inspector or by looking it up in the Dialogue Awake function.
In the quest script have the variable as “public static bool okay = false;” without the quotes.
Inside of your dialog script put “if(Gui.Button…) questSystem.okay = true;” also without the quotes.
It is this way for both UnityScript and C#, the only difference is in C# one must explicitly state PUBLIC as variables are private by default, whereas in UnityScript they are public by default.