Search Specific Actor Function

#Code

A search function designed to search for a specific Actor in the level.


Slap that function inside your script and call it as follows: SearchActor('ActorName', 12345);

To explain the parameters I will use TriggerVolume_107 as a reference.

Parameter 1 - Input the class name as found under the properties of the actor, e.g TriggerVolume_107 means to search for that it needs to be 'TriggerVolume' in the input. Parameter 2 - The ID of the actor, each actor to be differenate has a custom ID in the editor, this can be seen in the Actor's properties. e.g TriggerVolume_107 means to search for that specifically you need to look for ID 107 in the input.

Search Specific Actor Function

[RAW] [Download]

// Search a specific actor in the level! Note: If you are going to access an actor's variables.
// e.g something like Hat_Enemy_Mobster you need to initialize the return value like this
// Hat_Enemy_Mobster(SearchActor('Hat_Enemy_Mobster', 5));
function Actor SearchActor(Name objectName, int id)
{
    local Actor a;
 
    foreach class'Worldinfo'.static.GetWorldInfo().AllActors(class'Actor', a)
    {
        if(!a.IsA(objectName)) continue;
        if(String(a.Name) ~= (String(objectName) $ "_" $ id)) return a;
    }
 
    return None;
}