I’ve got this trigger entity giving players an effect upon entering it, but the effect refuses to show up. This is the code in the trigger entity upon touching:
[lua]function ENT:StartTouch( ent ) --Serverside
if ( ent:IsPlayer() and ent:Team() == TEAM_RUNNER ) then
local efdata = EffectData()
efdata:SetEntity( ent )
util.Effect( "player_launch", efdata ) --I'm sure this gets executed, I added a print() and it successfully printed
end
end[/lua]
And this is the effect:
[lua]function EFFECT:Init( data )
self.Ent = data:GetEntity()
self.DieTime = CurTime() + 2
print( "Effect created! Die Time: " .. self.DieTime, "CurTime: " .. CurTime(), "Entity: " .. self.Ent )
end
function EFFECT:Think( )
local vPos = self.Ent:GetPos()
local emitter = ParticleEmitter( vPos )
for i = 0, 100 do
local randdsir = VectorRand()
local particle = emitter:Add( "effects/spark", vPos )
if ( particle ) then
particle:SetVelocity( randdir * math.Rand( 5, 15 ) )
particle:SetLifeTime( 0 )
particle:SetDieTime( math.Rand( 0.4, 1.6 ) )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 2 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand( 0, 360 ) )
particle:SetColor( math.Rand( 150, 240 ), 50, 20, 200 )
particle:SetAirResistance( 0 )
particle:SetGravity( Vector( 0, 0, 0 ) ) //-700
end
end
emitter:Finish()
print( "Removed:", ( self.DieTime > CurTime() ) )
return ( self.DieTime > CurTime() )
end
function EFFECT:Render()
end
[/lua]
The effect doesn’t show up and the print functions don’t print anything. Any assistance here?