Tip:
Highlight text to annotate it
X
Hello and welcome
to my free video tutorial.
The subject of this tutorial
is persistent data in the UDK.
That means that we're going to be looking at how to save information
from a level to the hard drive
and then how to load that information back from the hard drive
to a level
a later time.
In short,
What we'll be doing is looking at how to build-in functionality into
our games
that will allow the gamer to load
and save their game.
We're going to do that by focusing on a
specific and simple example
that I have in front of us here.
This is going to be the result
of our work in this tutorial. This is going to show you
the end product.
To start with, let's take a look at this level. It has walls and a ceiling
and what we're going to be doing: is we're going to spawn some
actors into this level- some cube actors.
We're then going to save their location in the level
and we're then going to load back the level, and loading in those actors
and setting them to their
saved positions.
To do this I've coded some
console commands.
in UnrealScript. These commands will allow us to spawn actors and to
save
and load them.
So let's take a look at them now. If I click the 'play' button
on the
Editor toolbar here...
And I open up the Unreal console by pressing the tab key on the keyboard.
And into the Unreal Console I am going to type:
SpawnCube
and then I have to enter a position. This will tell
Unrealscript
where to generate a cube in the level.
So for the X coordinate
Let's say 297...
For the Y, let's say 350.
And for the Z, -330.
These values are not random values I have chosen. I know in advance
where these cubes
are going to appear. Press the enter key on the keyboard.
And a cube appears here
at the corner of the level.
Keep in mind that this is not editor mode.
It is the 'Play in editor' mode, so it counts as
'Running the level', as it were.
I'm going to generate two more cubes into the level.
Again, 'Spawn Cube'.
This time -63, 350, 329.
Press enter on the keyboard.
There's another cube; and one last cube. 'Spawn Cube'.
-63,
350 and 17.
We now have three cubes in the level.
Now let's say, for example, that I want to save this level.
I want to save the fact that
these three cubes have been spawned
and that they are at these positions.
Well, I have coded a function for this too. Press tab on the keyboard
and choose 'Save Game'.
And press enter on the keyboard.
My game
has now been saved.
So let's test this by trying to load it back. Press the esc key to exit
the 'Play in Editor' mode, and we're
now back to our
initial level here, with no cubes.
Let's replay the level.
Pressing the 'Play' key on the
toolbar again.
And now I'm going to open up the console, by pressing the tab key.
Typing 'LoadGame'
and press enter
on the keyboard.
And you'll notice that straight away
my cubes are loaded back into the level
at the positions at which we saved them.
So this tutorial is going to show you
how to achieve this kind of behavior.
It will require us to create
three classes- three separate classes in Unrealscript.