I'm having very inconsistent results trying to change global variables through a C# script. Earlier I was able to change the health value of an enemy through trial and error, eventually ending up with this set of code.
using AC
{
public GVar healthRecord;
healthRecord.FloatValue = enemy.health;
AC.GlobalVariables.SetFloatValue(9, healthRecord.FloatValue);
}
This method works. But when I tried it with a boolean variable at a later time, it does not change.
using AC
{
public GVar wonCellarPuzzle;
wonCellarPuzzle.BooleanValue=true;
AC.GlobalVariables.SetBooleanValue(22, wonCellarPuzzle.BooleanValue);
}
From what I understand I should just be able to write
AC.GlobalVariables.SetBooleanValue(22, true);
But that does not work either. Really confused as to how this system works.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You don't need to create a GVar class of your own - you can assign the values directly, i.e.:
If these aren't working, check that the types match - i.e. the variable with an ID of "22" is a Boolean.
It's also possible to refer to variables by name. Try this for the latter instead, replacing "WonCellarPuzzle" with the name of your Global Variable:
Does that work?