Game Engine Architecture

(Ben Green) #1

798 14. Runtime Gameplay Foundation Systems


Unreal), and object references (but not free-form pointers). In addition, Un-
realScript provides a number of extremely powerful game-specifi c features,
which we’ll explore briefl y below. UnrealScript is an interpreted, imperative,
object-oriented language.

Ability to Extend the Class Hierarchy
This is perhaps UnrealScript’s biggest claim to fame. The Unreal object model
is essentially a monolithic class hierarchy, with add-on components provid-
ing interfaces to various engine systems. The root classes in the hierarchy are
known as native classes, because they are implemented in the native C++ lan-
guage. But UnrealScript’s real power comes from the fact that it can be used to
derive new classes that are implemented entirely in script.
This may not sound like a big deal until you try to imagine how you
would implement such a thing! In eff ect, UnrealScript redefi nes and extends
C++’s native object model, which is really quite astounding. For native Unreal
classes, the UnrealScript source fi les (normally named with the extension .uc)
take the place of C++’s header fi les (.h fi les) as the primary defi nition of each
class—the UnrealScript compiler actually generates the C++ .h fi les from the .uc
fi les, and the programmer implements the classes in regular .cpp source fi les.
Doing this allows the UnrealScript compiler to introduce additional features
into every Unreal class, and these features permit new script-only classes to be
defi ned by users that inherit from native classes or other script-only classes.

Latent Functions
Latent functions are functions whose execution may span multiple frames of
gameplay. A latent function can execute some instructions and then “go to
sleep” waiting for an event or for a specifi ed amount of time to pass. When the
relevant event occurs or the time period elapses, the function is “woken up” by
the engine, and it continues executing where it left off. This feature is highly use-
ful for managing behaviors in the game that depend upon the passage of time.

Convenient Linkage to UnrealEd
The data members of any UnrealScript-based class can be optionally marked with
a simple annotation, indicating that that data member is to be made available for
viewing and editing in Unreal’s world editor , UnrealEd. No GUI programming
is required. This makes data-driven game design extremely easy (as long as Un-
realEd’s built-in data member editing GUI suits your needs, of course).
Network Replication for Multiplayer Games
Individual data elements in UnrealScript can be marked for replication. In
Unreal networked games, each game object exists in its full form on one
Free download pdf