UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Archetypes and Prefabs


46

There are a number of occasions when you may need to make use of archetypes, so let's
go through a few of them:


f Multiple deviations of an actor or object is necessary (that is, a ball which has
an assortment of colors)
f Altering objects within the editor, thereby making a level designer's role easier,
as they will not have to access the UnrealScript to make these changes
f Reduction of compile-time and load-time overhead, that is, you can have multiple
instances of the same object and the Unreal Engine simply sees it as one object,
thus lower computational overhead

Multiple deviations of an actor or object is necessary


Inheritance, or extending from a parent class, is a common practice in object-oriented
programming languages. This allows us to inherit all of the properties from a parent class,
as well as make changes to those properties in our new child class, while adding some new
functionality of our own.


If you want your functionality to stay the same but are looking to make content or data
driven differences (colors, particle effects, damage, and so on), then archetypes are an
excellent solution.


A simple enemy of multiple classes is an excellent example to use. Say you want to have a
scout class and a heavy weapons class in your game. Many of these changes are cosmetic,
so you may just be altering the clothing color so that they appear different, but you want
the scout to obviously run much faster than the heavy weapons, while also having a smaller
amount of health. Simply changing the default maximum hit points and run speed of these
two characters will create a great difference as well.


Altering objects within the editor


Like I mentioned before, with using Remote Control, tweaking values during runtime or while
in the editor is a quick way to iterate and allow non-programmers to make adjustments
without ever seeing the code.


You may find yourself in a situation where art assets for a project are not yet available, but you
understand the functionality you'll want out of an object. Therefore you can use placeholder
art, which will later be replaced with the final product, but in the mean time your time can be
spent putting the prototype into place.

Free download pdf