UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Archetypes and Prefabs


40


  1. Align the sound cue beneath the pipe. When you hit the PIE button, you'll notice that
    the sound gradually decreases as you move further from the pipe as well.

  2. Be sure to save your changes again.


How it works...


Just as before, the content browser offers quite a bit of value to our level designer, as it allows
him or her to quickly parse through our library of assets and drag content onto our map. Prefabs
can be created at any point when we select two or more components at the same time.


See also


Try adding some water beneath the piping, so that your stream is flowing into a pool of water.
How do you think the sound of the water would change? See if you can find an appropriate
sound cue for water splashing against another water source.


Creating a PointLight archetype


Archetypes and prefabs share a number of similarities, but most noticeably in that we use them
to create instances of an object. All instances of an archetype on a map will update when an
archetype is stored in a package, and that's one of the convenient reasons for using them.


Furthermore, if you chose to only alter an instance of an archetype, then the rest of those on
the map will remain the same! So you have both ends of the spectrum, all within one tool.
Archetypes also allow us to create physical representations of our code, to be manipulated
and edited within the UDK editor, and later used in the game itself.


Archetypes are different from prefabs in three distinct ways:


f Prefabs can be composed of archetypes
f Prefabs can contain sequences (Kismet)
f Prefabs preserve and translate object references within the prefab

In the editor, archetypes are represented as placeable items, much like how classes are
placeable resources. Archetypes are often thought of as "script less classes", in that their
purpose is to provide a way for designers to drop an actor that uses a set of default property
values, which are different from the actor's class defaults. They also appear in the content
browser, and provide the same functionality as any other resource type.


By default, the scripts and classes you write for UDK will appear in the Actor Classes tab,
adjacent to the Classes Browser tab in the editor. By converting our classes to archetypes we
can visually edit properties for these classes, thereby allowing for changes on the fly, instead of
constantly having to change code in the IDE, rebuild, and then view our changes in the editor.

Free download pdf