Gah - a solution with more questions. – EntropicLqd

Actor

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 19:39, 27 March 2010 by 128.187.0.164 (Talk)

Jump to: navigation, search
Object >> Actor
Package: 
Engine
Direct subclass:
Info
This class in other games:
RTNP, U1, UT, UE2Runtime, UT2003, U2, UT2004, U2XMP, UT3, UDK


Actor is the parent class of all objects that have a co-ordinate position in the world. The Actor can move around, interact with other actors, and affect the environment.


Properties

Owner

Tag

Level

Functions

Spawn

The Spawn() function is best described by its UE3 declaration:

native noexport final function coerce Actor Spawn (class<ActorSpawnClass, optional Actor SpawnOwner, optional name SpawnTag, optional Object.Vector SpawnLocation, optional Object.Rotator SpawnRotation, optional Actor ActorTemplate, optional bool bNoCollisionFail)

(The last two parameters do not exist in earlier engine generations.)

All except the first parameter are optional. The function is not static, so you always need some actor reference to create other actors.

You may have noticed the keyword coerce in that unusual place already. It points out that the compile-time return type of the Spawn() function corresponds to the metaclass of the first parameter's type. Consider the following UT3-based examples:

local class<UTHud> UHClass< SEMI >
local class<Hud> HClass< SEMI >
local Hud H;
local UTHud UH;
 
UHClass = class'UTHud';
HClass = class'UTHud';
 
UH = Spawn(class'UTHud'); // works because UTHud extends Hud
UH = Spawn(UHClass); // works because the metaclass of UHClass is UTHud
H  = Spawn(UHClass); // works because UTHud extends Hud
H  = Spawn(HClass);  // works because the metaclass of HClass is Hud
UH = Spawn(HClass);  // type mismatch error (Hud doesn't extend UTHud!)

The native code behind the Spawn() function causes several UnrealScript functions to be called on the newly created actor (and possibly also on other actors) before it returns the new actor. See What happens when an Actor is spawned for details.

To create non-actor objects, use the operator New instead.

Iterator functions

AllActors