btw if you set DynamicLight view, UE crashes (there is more that thousand light sources in small area

https://wetransfer.com/downloads/1ad421 ... 901/76c4fc
Code: Select all
//=============================================================================
// LightPath. by Daewon
//=============================================================================
class LightPath expands Light;
var() float DistanceBetween, ChangeTime; // distance to next Light
var float InitialBrightness, RadiusCheck; // Initial brightness.
var float Alpha, Direction;
var() byte ChainNum; // chain id
var() bool bshowLight; // debug
var() vector SkipToLocation;
var vector NextLoc;
simulated function BeginPlay()
{
Disable( 'Tick' );
InitialBrightness = LightBrightness;
Alpha = 0.0;
Direction = -1.0;
RadiusCheck = DistanceBetween/2;
if(SkipToLocation==vect(0,0,0))
NextLoc = Location + DistanceBetween * Vector(Rotation);
else
NextLoc = SkipToLocation;
if(!bshowLight)
DrawType = DT_None;
}
function Tick( float DeltaTime )
{
Alpha += Direction * DeltaTime / ChangeTime;
if( Alpha > 1.0 )
{
Alpha = 1.0;
Disable( 'Tick' );
}
else if( Alpha < 0.0 )
{
Alpha = 0.0;
Disable( 'Tick' );
}
LightBrightness = Alpha * InitialBrightness;
}
// Trigger turns the first light on.
auto state PathLightTriggerON
{
function Trigger( actor Other, pawn EventInstigator )
{
GoToState('PathLightON');
}
}
state PathLightON
{
function BeginState()
{
Direction = 1.0; // light turns on
Enable( 'Tick' );
SetTimer (ChangeTime, false);
}
function Trigger( actor Other, pawn EventInstigator )
{
}
function Timer () {
local LightPath N;
foreach RadiusActors( class 'LightPath', N, RadiusCheck, NextLoc ){
if(N.ChainNum==ChainNum) // same chain
N.Trigger(self, self.instigator);
}
GoToState('PathLightOFF');
}
}
state PathLightOFF
{
function BeginState()
{
Enable( 'Tick' );
Direction = -1.0; // light turns off
SetTimer (ChangeTime, false);
if(bshowLight)
DrawScale = 0.5;
}
function Timer () {
if(bshowLight)
DrawScale = Default.DrawScale;
GoToState('PathLightTriggerON');
}
}