Actor Intro

Actor is the base class of all objects that may be placed in the map. In most situations, this will be the base class of objects in your map that don't need to be derived from anything more specific. Seeing as it is the base class of all placeable objects in the map, let's take a look at the various functionality it provides as this functionality will be made available to all classes that descend from it, including your own.

Location, Rotation, Scale

Since all Actor objects can be placed in the map, the Actor class contains the properties required to store transformation information. That is, the position, rotation, and scale of the object.

Location

/** Actor's location; use Move or SetLocation to change. */
var(Movement) const vector            Location;

Location is the position of the Actor in the map. It is defined in Actor.uc as a vector.

Rotation

/** The actor's rotation; use SetRotation to change. */
var(Movement) const rotator            Rotation;

Rotation is the amount of 3D angular offset this Actor has from the default rotation. It is stored as a rotator.

Scale

/** Scaling factor, 1.0=normal size. */
var(Display) const repnotify interp    float    DrawScale <UIMin=0.1 | UIMax=4.0>;

/** Scaling vector, (1.0,1.0,1.0)=normal size. */
var(Display) const interp    vector    DrawScale3D;

Scale is a factor that affects the current size of an object. Scale tends to be tricky/glitchy for game engines. In the UDK, Actor has two scaling variables:

  • DrawScale
  • DrawScale3D

DrawScale is a floating point variable while DrawScale3D is a vector. DrawScale is known as a uniform scale because it applies evenly to all 3 dimensions of the object. DrawScale3D on the other hand is a vector and affects each dimension differently since it has 3 members: X, Y, Z. Note: While DrawScale/DrawScale3D will always affect the representation of an Actor correctly (ie particles, meshes, etc...), it may not affect the collision of the actor correctly.

Functions

Actor contains some of the most useful functions in the UDK. We will look at two in this article; a more exhaustive list will be examined in a later article. For a reference, read Actor.uc.

PlayerController GetALocalPlayerController()

This function returns a player controller locally present at this computer. If none is present, this returns none. If more than one player controller exists (split screen), one of the player controllers is returned. Otherwise, the player controller of the player sitting at this computer is returned.

Actor Spawn(...)

Spawn's signature looks as follows:

native noexport final function coerce actor Spawn
(
    class<actor>      SpawnClass,
    optional actor      SpawnOwner,
    optional name     SpawnTag,
    optional vector   SpawnLocation,
    optional rotator  SpawnRotation,
    optional Actor    ActorTemplate,
    optional bool      bNoCollisionFail
);

The spawn function is used to instantiate an Actor. The class of actor to instantiate is passed in as the first parameter. An optional spawn location and rotation could be provided, otherwise the actor is spawned at the current actor's transform.

SetTimer(...)

/**
 * Sets a timer to call the given function at a set
 * interval.  Defaults to calling the 'Timer' event if
 * no function is specified.  If InRate is set to
 * 0.f it will effectively disable the previous timer.
 *
 * NOTE: Functions with parameters are not supported!
 *
 * @param InRate the amount of time to pass between firing
 * @param inbLoop whether to keep firing or only fire once
 * @param inTimerFunc the name of the function to call when the timer fires
 */
native(280) final function SetTimer(
    float InRate,
    optional bool inbLoop,
    optional Name inTimerFunc='Timer',
    optional Object inObj);

Causes a function to be called after a specified amount of time.

Properties:

  • float InRate
    • Time in seconds before the target function is called
  • optional bool inbLoop
    • Whether the target function should be called repeatedly in a loop
  • optional name inTimerFunc='Timer'
    • The name of the target function to call on this actor. Defaults to the function Timer
  • optional Object inObj
    • Target object to call the target function on. Defaults to the current Actor

String GetHumanReadableName()

Returns a friendly name to refer to this Actor as.