UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Archetypes and Prefabs


34

Prefabs are tied to the original assets through references, therefore if you make a change to
an asset, the next time you load UDK the changes will be applied to the prefab. This allows for
quick and dynamic prototyping, as you can create a prefab ahead of time, using placeholder
objects that you know you'll need, and adjust the aesthetics at a later time when the assets
are ready from the artist or modeler on your team.


That's the purpose of a prefab, to simplify your life and streamline the development process.


Constructing a leaking pipe prefab


Prefabs are simply a combination of multiple objects and actors within a scene. We can
combine virtually any item in UDK to create one.


Getting ready


We'll begin by loading the map that contains our example prefab. This will allow you to see the
various components used to create one, as well as teach you to create one of your own. Along
the way you'll have to manipulate certain objects such as rotating a pipe or adjusting the scale
of a waterfall, but this won't be anything overly complicated.


How to do it...


To get things started, let's open up a new map called Chapter2 under the Tutorials
folder. This will have the chapter's prefab and archetype already in place for you, so that
you can see the end result of your work, and what it should look like. Fortunately, all of our
in-game assets can be accessed through the ever useful content browser. Let's begin by
looking in the following:



  1. Open the Content Browser tab and drag the static mesh S_HU_Deco_PipesSM
    PipeSet_B01 into the scene. This will serve as the static mesh for the pipe itself.

  2. Rotate the pipe by 90 degrees, so that it is horizontal, to match the following
    screenshot. Pressing the Space bar allows the widget to change from translation
    to rotation.

  3. Our pipe is looking pretty bland by itself, so let's add some flowing water to it. Also
    under static meshes, you'll find S_UN_Liquid_SM_Waterfall_02. Drag that into
    the scene as well.

  4. Line up the center of the waterfall with the center of the pipe. It's still a bit too large
    for the pipe, but we'll fix that in the next step.

  5. Adjust the scale of the waterfall on the x plane, so that it appears small enough to
    actually be falling from the pipe.

Free download pdf