Time for action – Using booleans
The first thing we need to do is tell the game about our variable. This is called declaration. Variables need to be declared before they can be used. Our declaration tells the game what type of variable it is as well as its name.
We'll continue with our "is it raining?" scenario for this experiment. In a game we might want to use this variable to check whether we should spawn rain effects or make changes to the lights, and so on.
Variable declaration in UnrealScript happens after the class declaration line, and before any functions. Let's add a variable to AwesomeActor.uc
to see if it's raining or not.
Open up our
AwesomeActor.uc
class in ConTEXT and add this line after our class declaration:var bool bIsItRaining;
The
var
tells the game that we're declaring a variable. After that, is the variable type, in this casebool
for boolean. After that, we tell the game our variable's name,bIsItRaining
. Spaces can't be used in variable names, but underscore characters...