Legacy:VitalOverdose/SFXTriggering

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search
UT2004 :: Actor >> Emitter >> SFXTriggering (Package: custom)

by VitalOverdose

Overview

This custom emitter script can tack a set amount of particles (20) from an emitter and trigger an event on collision with pawns. The event to trigger can be set by the mapper in unrealed.

PostBeginPlay()

(generic:called just after it enters gameplay)

here the max particle property is check to see if it is under 21 particles and then the timer function is activated using 'timer frequncy' to set the scan rate.

<uscript> Simulated function PostBeginPlay() {

Super.PostBeginPlay();
 If ( Emitters[ActiveEmitterNumb].MaxParticles > 20)           //active particles capped to max20
    Destroyed();
 If (TimerFrequency<0.1)
    TimerFrequency = 0.1;
SetTimer( TimerFrequency , True );

} </uscript>

function Timer()

Each time timer is called the live particles from this emitter will be located and then have their location scanned for a valid collision. We are able to list all visible colliding actors by using an iterator.

(generic:called to order)

<uscript> Simulated Function Timer() {

Local Actor           FoundActor;
Local Int             Counter;
for ( Counter=0 ; Counter < Emitters[0].Particles.Length ; Counter++ )
     foreach visiblecollidingActors(Class'Actor', FoundActor , ScanSize , Emitters[ActiveEmitterNumb].Particles[Counter].Location )
              TriggerEvent( CollidedWith.Tag , Self , Instigator );

} </uscript>


Here is the complete script;-

Full Script

<uscript> //////////////////////////////////////////////// //Class SFXTriggering for Unrealtournament 2004 //Single player only //by VitalOverdose Jan 2006 //Http://vitaloverdose.zapme.to.org /////////////////////////////////////////////// class SFXTriggering Extends Emitter placeable;

Var int TotalParticles; Var () int ActiveEmitterNumb; Var () int TimerFrequency; Var () Float ScanSize;

Simulated function PostBeginPlay() {

Super.PostBeginPlay();

//active particles capped to max20

If ( (Emitters[ActiveEmitterNumb].MaxParticles > 20) || (TimerFrequency<0.1))           
    Destroyed();

// start the timer function and set it to repeat

SetTimer( TimerFrequency , True );

}

Simulated Function Timer() {

Local Actor           FoundActor;
Local Int             Counter;

//itterate through the any visible colliding actors withing 'scansize' radius of the particle location calling TriggerEvent() each time for ( Counter=0 ; Counter < Emitters[0].Particles.Length ; Counter++ )

     foreach visiblecollidingActors(Class'Actor', FoundActor , ScanSize , Emitters[ActiveEmitterNumb].Particles[Counter].Location )
              TriggerEvent( CollidedWith.Tag , Self , Instigator );

}

defaultproperties { bNoDelete=False RemoteRole=ROLE_SimulatedProxy } </uscript>

Related Topcs

More custom emitter scipts

Discussion