I don't need to test my programs. I have an error-correcting modem.

Difference between revisions of "Actor"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(stub for the Actor class in general)
 
m (Spawn: added description)
Line 12: Line 12:
 
==Functions==
 
==Functions==
 
====Spawn====
 
====Spawn====
 +
The Spawn() function is best described by its [[UE3]] declaration:
 +
{{code|native noexport final function coerce {{cl|Actor}}&nbsp;'''Spawn''' ([[class]]<{{cl|Actor}}>&nbsp;'''SpawnClass''', optional&nbsp;{{cl|Actor}}&nbsp;'''SpawnOwner''', optional&nbsp;[[name]]&nbsp;'''SpawnTag''', optional&nbsp;[[Vector|Object.Vector]]&nbsp;'''SpawnLocation''', optional&nbsp;[[Rotator|Object.Rotator]]&nbsp;'''SpawnRotation''', optional&nbsp;{{cl|Actor}}&nbsp;'''ActorTemplate''', optional&nbsp;[[bool]]&nbsp;'''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:
 +
<uscript>
 +
local class<UTHud> UHClass;
 +
local class<Hud> HClass;
 +
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!)
 +
</uscript>
 +
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===
 
===Iterator functions===
 
====AllActors====
 
====AllActors====

Revision as of 13:37, 4 March 2010

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


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