Cogito, ergo sum
Actor
Object >> Actor |
- Package:
- Engine
- Direct subclass:
- Info
- This class in other games:
- RTNP, U1, UT, UE2Runtime, UT2003, U2, UT2004, U2XMP, UT3, UDK
This article related to UnrealScript or the UnrealScript API is a stub. You can help Unreal Wiki by expanding it. |
Properties
Owner
Tag
Level
Functions
Spawn
The Spawn() function is best described by its UE3 declaration:
(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.