You could also use a setup like this (although this results in many more actors being placed in the level):
Code:
class AverageColorActor extends Actor
placeable;
var() color AverageColor;
var() Actor AttachTo;
function PostBeginPlay()
{
if (AttachTo != none)
{
//attach ourself to AttachTo, so we are able to get a reference to this AverageColorActor (and its AverageColor attribute).
//Say we have a reference to an Actor, which may be aquired using Trace() or similar, we pass it to the static function below and get an AverageColorActor (or none) back.
AttachTo.Attach(self);
}
}
//returns the first AverageColorActor that is attached to anActor
static final function AverageColorActor findActorInAttached(Actor anActor)
{
local int i;
if (anActor != none)
{
for (i = 0; i < anActor.Attached.length; i++)
{
if (AverageColorActor(anActor.Attached[i]) != none)
{
return AverageColorActor(anActor.Attached[i]);
}
}
}
return none;
}
Bookmarks