-
Book Overview & Buying
-
Table Of Contents
Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide
By :
We'll use a function we haven't used yet for this so we can keep it easily readable. In addition to PostBeginPlay, all Actor classes have a PreBeginPlay event that is called before PostBeginPlay during startup. We'll use this for our experiments.
Local variables are declared like instance variables, except we use local in the declaration line. Local variables can only be declared inside a function, and must be at the top of the function before any other lines of code. To see for ourselves, let's make a PreBeginPlay function in our AwesomeGame class:
function PreBeginPlay()
{
super.PreBeginPlay();
local int i;
i = 5;
`log("This is i:" @ i);
}If we try to compile this, we'll get a compiler error:
Error, 'Local' is not allowed here
Let's try rearranging the PreBeginPlay function to move the variable declaration to the top:
function PreBeginPlay()
{
local int i;
super.PreBeginPlay();
i = 5;
`log("This is i:" @ i);
}It compiles...
Change the font size
Change margin width
Change background colour