Attaching a Particle to an Entity

Hello, I have a nextbot npc, and I want to attach the “Community Sparkle” effect from TF2 onto it.
I have this code, but it doesn’t seem to work.



function ENT:Precache()
util.PrecacheParticleSystem("community_sparkle")
end

function ENT:Initialize()
	self:SetHealth(self.health)
	self:SetModel( "My model Here" );
--PrecacheParticleSystem("community_sparkle")
ParticleEffectAttach("community_sparkle",PATTACH_ABSORIGIN_FOLLOW,ENT,0)
end


No lua errors, so there is nothing to refer to.
Would apprecaite any help :dance:

ENT:Precache doesn’t exist, and so does util.PrecacheParticleSystem.

First, you must add the pcf you are about to use with game.AddParticle. Then you must precache every effect with PrecacheParticleSystem global function. Only then you attach the thing with ParticleEffectAttach.

You call the first two functions on top of the file, outside of any of the hooks or functions or ifs.

[editline]18th June 2014[/editline]

By the way, I have seen you report an addon as “stolen from you”, if you still claim that it is ( the alyx player model one ), show me some proof over PM or something.

Hello Rubat, thanks alot for replying :dance:
I have modified the code



game.AddParticles( "particles/item_fx.pcf" )
PrecacheParticleSystem( "community_sparkle" )

function ENT:Initialize()
	self:SetHealth(self.health)
	self:SetModel( "models/Errol/SonicJam/SuperSonicJam.mdl" );
--PrecacheParticleSystem("community_sparkle")
ParticleEffectAttach("community_sparkle",PATTACH_ABSORIGIN_FOLLOW,ENT,0)
end


But it didn’t work.

I am assuming by that you meant ALL of the particles in the pcf, rather then the one I wanted, if that is so, I shall make the change. :eng101:

No, only for the ones you need to show.

In your case, ENT is nil inside ENT:* function, use self instead of ENT in ParticleEffectAttach

Ah, that did it :smile:
Thanks again for the help, I really appreciate it.
I believe I’ve sent you a message regarding addons