There is no spoon

Actor

From Unreal Wiki, The Unreal Engine Documentation Site
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


Properties[edit]

Owner[edit]

Tag[edit]

Level[edit]

Functions[edit]

Spawn[edit]

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.

Destroy[edit]

native final function bool Destroy ()

Calling this function on a destructible actor will remove that actor permanently. An actor is destructible if its bNoDelete and bStatic properties are False. On network clients a replicated actor can only be destroyed if its bNetTemporary property is True. If that property is False, the replicated actor will only be destroyed if it is no longer relevant to the client or was destroyed on the server. This happens automatically and has the same effects as if Destroy() was called on the actor.

If the actor is allowed to be destroyed, this function will return True after removing the actor, otherwise it returns False. If Destroy() returns True, all former references to the actor are safely cleared, i.e. they behave as if they were assigned the value None.

There is special handling for PlayerPawns and PlayerControllers corresponding to a client on a network server, which are not destroyed right away. Destroy returns False, as the player actor is not removed, but it initiates a disconnect.

The native code behind the Destroy() function causes several UnrealScript functions to be called during destruction and before the function returns. See What happens when an Actor is destroyed for details.

Note that non-actor Objects cannot be destroyed explicitly. To get rid of an object, you need to unset all references to it. Once an object is no longer referenced, the garbage collector will discard it. Garbage collection does not cause any UnrealScript events to be called on the object.

Iterator functions[edit]

AllActors[edit]