| Home Page | Recent Changes | Preferences

Dispatcher

UT :: Actor (UT) >> Triggers (UT) >> Dispatcher (Package: Engine)

Replaced in UT2003 by the ScriptedTrigger.

A dispatcher is a Trigger meant for taking another Trigger's Event and sending out a bunch of new events. The dispatcher also has the capability to time when to send out these subsequent events. It is important to point out that the location of a dispatcher is totally irrelevant to its function: it is not affected by players touching it. However, it is generally advisable to put a dispatcher near to the trigger that it will be triggered by or the actors that it will in turn trigger just for organization's sake.

Properties

OutEvents
list of events the dispatcher will fire, in order. Note that UnrealEd will not draw a red line to tiw actors whose Tag matches these events. (If you're paranoid about this, type the event name in the wrong case; UnrealEd will fix the case if there's a match). If you wish to make more than 7 events, link in a second dispatcher.
OutDelays

the time to wait before firing the corresponding event. These are sequential; ie the dispatcher works like this:

  • wait time OutDelays[0]
    • fire event OutEvents[0]
  • wait time OutDelays[1]
    • fire event OutEvents[1]
  • and so on.

These can be equal to zero; thus firing several events simultaneously.

Examples

Simple example

An example would be if you want the dispatcher to trigger 3 events upon the event "xxx" being sent out. The 3 events you want to send out are "yyy" at the same time that "xxx" was sent out, "yyy" again 20 seconds later, and "zzz" at the same time as the second "yyy". The properties you would fill in would be this:

  • OutDelays
    • 0 - 0.0
    • 1 - 20.0
    • 2 - 0.0
  • OutEvents
    • 0 - yyy
    • 1 - yyy
    • 2 - zzz

Delaying

There is another good trick that can be done with Dispatchers. Sometimes you need to trigger something, but then you need to make it wait before the actual Event happens. This can be done by putting a Dispatcher between the two Events in the chain.

So, if you triggered the Dispatcher's tag xxx, but you needed it to wait 5 seconds before it triggered aaa, here's how it will look:

  • OutDelays
    • 0 - 5.0
  • OutEvents
    • 0 - aaa

Notice that you're not doing anything except triggering an actor that will wait 5 seconds. This is a little trick that editors will sometimes use for such things as properly timing their special effects.

Note that a dispatcher's OutDelays are cumulative. In other words, if you have:

  • OutDelay 1
  • OutDelay 3
  • OutDelay 4

Then the second event is called three seconds after the first, and four seconds after the dispatcher is triggered, and the third event four seconds after the second, and eight seconds in total from the time the dispatcher is called.

Further examples

Related Topics

  • Dynamics – main page for everything about triggers
  • Event – overview of how triggering works
  • Types of Trigger – summary of the different kinds of trigger actor

Custom Subclasses

Haltable dispatcher

Tarquin: A dispatcher which stops if triggered while dispatching. This is untested; I have no idea what happens to state label code when a function is called. see Create A Subclass for instructions.

state Dispatch
{
    function Trigger( actor Other, pawn EventInstigator )
    {
        gotostate('');
    }

Begin:
    for( i=0; i<ArrayCount(OutEvents); i++ )
    {
        if( OutEvents[i] != '' )
        {
            Sleep( OutDelays[i] );
            foreach AllActors( class 'Actor', Target, OutEvents[i] )
                Target.Trigger( Self, Instigator );
        }
    }
}

Elephant Dispatcher

Normal Disp breaks the chain of command. This remembers who Triggered it and passes this information on to the actors it triggers. See Event for details.

//=============================================================================
// ChainDispatcher.
//=============================================================================
class ChainDispatcher extends Dispatcher;
// Remembers who Triggered it 
// and passes this information along the chain of command

var actor SavedTrigger ;

//
// When dispatcher is triggered...
//
function Trigger( actor Other, pawn EventInstigator )
{
    SavedTrigger  = Other ;
    super.Trigger( Other, EventInstigator );
}

//
// Dispatch events.
//
state Dispatch
{
Begin:
    disable('Trigger');
    for( i=0; i<ArrayCount(OutEvents); i++ )
    {
        if( OutEvents[i] != '' )
        {
            Sleep( OutDelays[i] );
            foreach AllActors( class 'Actor', Target, OutEvents[i] )
                Target.Trigger( SavedTrigger, Instigator );
        }
    }
    enable('Trigger');
}

Category Class (UT)
Category Custom Class

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In