util.Effect only works clientside?

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

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 )


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

print( "Removed:", ( self.DieTime > CurTime() ) )

return ( self.DieTime > CurTime() )


function EFFECT:Render()
The effect doesn’t show up and the print functions don’t print anything. Any assistance here?

[lua]util.Effect( “player_launch”, efdata, true, true )[/lua]

You could also have looked at the code for the emitter entity, the one that gets created by the emitter tool.

Still appears to do nothing :saddowns:

If the map origin (0,0,0) is outside the world then the effect won’t even bother sending to the client as it is deemed not visible. Set the origin of the effect to the entity’s origin.

[lua]efdata:SetOrigin( ent:GetPos() );[/lua]

It worked! Many thanks :fuckyou:

It appears that there’s a bug with the LookupBone and GetBonePosition functions. I have this in my effect’s think hook.
[lua]function EFFECT:Think( )

local lbone = self.Ent:LookupBone( "ValveBiped.Bip01_L_Foot" )
local rbone = self.Ent:LookupBone( "ValveBiped.Bip01_R_Foot" )
local lbonepos, lboneang = self.Ent:GetBonePosition( lbone )
local rbonepos, rboneang = self.Ent:GetBonePosition( rbone )

self:EmitEffect( lbonepos )
self:EmitEffect( rbonepos )

return ( self.DieTime > CurTime() )

In game, when the effect is active, it appears to make the player enable full rotation and rotates the whole body to the direction you’re looking in, see this picture:


Disabling the effect eliminates this bug and the player keeps being upright, see this picture:


Any workaround or fix for this?

Try using **[Player.SetAllowFullRotation


I figured I’d rather not use this, because I’d need to execute this function every frame after using the bone functions to make the player stay upright. But if there’s no other solution, I’ll use this as a last resort.

If I remember correctly, calling self.Ent:InvalidateBoneCache() before or after doing all your bone operations fixes that. Not sure though.

Also, there’s another problem: SetAllowFullRotation is serverside, so I can’t use it in the effect… :frown:


I’ll try this.


It works, wohoo! :buddy: