UnrealScript languagehistorical
Epic's native Unreal Engine scripting language: a single-inheritance, compile-time-checked object system with states, latent functions and replication built in. Removed in Unreal Engine 4 in favour of C++ and Blueprints.
Overview
UnrealScript is Epic's built-in scripting language for Unreal Engine 1 through 3, a Java-style object-oriented language designed by Tim Sweeney for gameplay code. It puts time, actor state, and network replication into the language itself, so gameplay logic reads as linear sequences rather than frame bookkeeping.
Code
class Counter extends Object;
var int Count;
var float Rate;
function string Describe()
{
Count = 42; // int
Rate = 1.5; // float
return "count " $ string(Count); // $ joins, the cast renders the number
}
var array<int> Scores;
var vector Offset;
function Grow()
{
local int Each;
Scores.AddItem(7); // dynamic array append
Offset = vect(1.0, 2.0, 3.0); // struct-typed literal
Offset.Z = Offset.Z * 2.0; // member access
foreach Scores(Each) // iterate the elements
`log("p" @ Each);
}
class DoorTrigger extends Actor;
function Touch(Actor Other)
{
Super.Touch(Other); // the inherited implementation
GotoState('Opening'); // applied when state code resumes
}
var() float OpenTime; // editable in UnrealEd
state Opening
{
Begin:
Sleep(OpenTime); // latent: resumes after game time
Stop; // state code halts until the next transition
}
defaultproperties
{
OpenTime=2.0
}
Super reaches its inherited version;
foreach
walks the dynamic array;
Sleep is
latent — only state code may call it, entering at Begin, and the
defaultproperties
tail plays the constructor's part.Distinctive traits
- States are
language-level: each actor is in exactly one, their functions shadow global ones, and
PushState/PopStatestack them. - Latent functions inside state code make timed sequences linear; the engine simulates a per-actor thread instead of running OS threads.
- Replication
is declared, not coded:
server,client,reliableandsimulatedspecifiers place each function, andrepnotifymarks variables to notify on. defaultpropertiesreplaces constructors and feeds UnrealEd's editable properties marked withvar(); classes have no constructors or destructors.- Single inheritance from
Objectwith compile-time type checking, garbage collection, and case-insensitive identifiers throughout. - Speed was traded for safety deliberately: the 1998 reference measures scripts at roughly 20× slower than C++, so heavy work stayed in native code.
Status
Historical: it shipped with Unreal in 1998 and served Engine 1 through 3, including Unreal Tournament. Epic dropped it for Unreal Engine 4, moving gameplay code to C++ and Blueprints; the UDK documentation remains its reference.
Sources & references
- Official sitedocs.unrealengine.com
- UnrealScript Language Reference — Unreal Development Kit documentation (Epic Games)docs.unrealengine.com
- UnrealScript Language Reference — Tim Sweeney, Epic MegaGames (1998 original, archived)web.archive.org
- UnrealScript States — Unreal Development Kit documentationdocs.unrealengine.com
- UnrealScript Default Properties — Unreal Development Kit documentationdocs.unrealengine.com
- Networking & Replication — Unreal Development Kit documentationdocs.unrealengine.com
- Epic's Tim Sweeney lays out the case for Unreal Engine 4 — Game Developer (2014)gamedeveloper.com