I give you the code:
Code: Select all
//=============================================================================
// DeeltjesUitzender.
//=============================================================================
class DeeltjesUitzender expands Triggers;
var() bool bRepeat;
var() Texture ParticleTexture;
var() float ParticleSpeed,Radius,ParticleDuration,ParticleSize,ParticleSpawnRate;
var() int NumParticles;
var() enum EAreaType
{
AT_Square,
AT_Sphere,
AT_Circle,
}
AreaType;
var bool bRecycling;
var vector X,Y,Z;
Function PostBeginPlay()
{
super.postbeginplay();
GetAxes(Rotation,X,Y,Z);
SetTimer(ParticleSpawnRate,bRepeat);
}
simulated function SetRecycle(Deeltjuh D)
{
local int i;
local float t,t2;
local vector RandLoc;
bRecycling = true;
if(AreaType == AT_Circle)
{
t = FRand()*2*pi;
t2 = Sqrt(FRand());
RandLoc = radius*t2*cos(t)*Z + radius*t2*sin(t)*Y;
}
else if(AreaType == AT_Square)
RandLoc = (Radius - 2*FRand()*Radius) * Z + (Radius - 2*FRand()*Radius) * Y;
else if (AreaType == AT_Sphere)
D.Velocity = VRand() * ParticleSpeed;
D.SetLocation(Location+RandLoc);
D.SetRotation(Rotation);
}
Simulated Function Timer()
{
local int i;
local vector RandLoc;
local Deeltjuh B;
local mover M;
local float t,t2;
if(bRecycling)
return;
For(i=0;i<NumParticles;i++)
{
if(AreaType == AT_Circle)
{
t = FRand()*2*pi;
t2 = Sqrt(FRand());
RandLoc = radius*t2*cos(t)*Z + radius*t2*sin(t)*Y;
}
if(AreaType == AT_Square)
RandLoc = (Radius - 2*FRand()*Radius) * Z + (Radius - 2*FRand()*Radius) * Y;
B = Spawn(class'Deeltjuh',self,,Location + RandLoc,Rotation);
if(AttachTag != '')
ForEach AllActors(class'Mover',M,AttachTag)
B.SetBase(M);
if (AreaType == AT_Sphere)
B.Velocity = VRand() * ParticleSpeed;
else
B.Velocity = Vector(Rotation) * ParticleSpeed;
B.DrawScale = ParticleSize;
B.ParticleDuration = ParticleDuration;
B.Texture = ParticleTexture;
}
}
Code: Select all
//=============================================================================
// Deeltjuh.
//=============================================================================
class Deeltjuh expands Actor;
var float ParticleDuration,Count;
replication
{
reliable if(Role==Role_Authority)
ParticleDuration,Count;
}
simulated function Tick( float DeltaTime )
{
Count += DeltaTime;
ScaleGlow = (ParticleDuration-Count)/ParticleDuration;
if(Count >= ParticleDuration)
{
ScaleGlow = 0;
Count = 0;
DeeltjesUitzender(Owner).SetRecycle(self);
}
}