• Emitting an EFFECT
    9 replies, posted
Hey. I need a little bit of help with an entity. Basically, I have an EFFECT, that I would like to emit out of a players head once the entity is spawned, and once the entity is deleted, the Effect stops emitting. IS there any way I could go about this? Thanks alot.
Is the effect looping?
[QUOTE=freemmaann;23622064]Is the effect looping?[/QUOTE] I am unsure. Sorry.
he means will the effect keep emitting over and over until the entity is removed or will it only emit once when it is spawn?
[QUOTE=JamesFoil;23623073]I am unsure. Sorry.[/QUOTE] Its not looping which makes things easy, ok this what you have to do: If you dont want anything specific like attaching the effect to eyes/mouth you just do this to emit the effect[LUA]--getshootpos is always from head, if you want it simple, witout attaching it to the heads bone do this local effectdata = EffectData() effectdata:SetAngle(self.Owner:GetAimVector()) effectdata:SetOrigin(self.Owner:GetShootPos()) effectdata:SetEntity(self.Owner) util.Effect("<<Effect name>>", effectdata)[/LUA]If you dont like where its comming from adjust it the pos by: [CODE]effectdata:SetOrigin(self.Owner:GetShootPos()<<+ self.Owner:GetRight()* << ammount you want it to go right>>) also there are GetForward/GetUp. Forget the above... Just use this:[LUA] local effectdata = EffectData() effectdata:SetOrigin(self:GetOwner():GetAttachment(self:GetOwner():LookupAttachment("anim_attachment_head")).Pos) effectdata:SetAngle(self:GetOwner():GetAttachment(self:GetOwner():LookupAttachment("anim_attachment_head")).Ang) effectdata:SetEntity(self:GetOwner()) effectdata:SetAttachment(self:GetOwner():LookupAttachment("anim_attachment_head")) util.Effect("<<Effect name>>", effectdata)[/LUA]
[QUOTE=freemmaann;23633879]Its not looping which makes things easy, ok this what you have to do: If you dont want anything specific like attaching the effect to eyes/mouth you just do this to emit the effect[LUA]--getshootpos is always from head, if you want it simple, witout attaching it to the heads bone do this local effectdata = EffectData() effectdata:SetAngle(self.Owner:GetAimVector()) effectdata:SetOrigin(self.Owner:GetShootPos()) effectdata:SetEntity(self.Owner) util.Effect("<<Effect name>>", effectdata)[/LUA]If you dont like where its comming from adjust it the pos by: [CODE]effectdata:SetOrigin(self.Owner:GetShootPos()<<+ self.Owner:GetRight()* << ammount you want it to go right>>) [/code] also there are GetForward/GetUp.[/QUOTE] Thanks for the help, but will you be willing to do me a favour and show me how to make this an Entity, like I said before. I am not so smart with the Lua language. :) Thanks alot.
Hm, I tried a little, but now it's giving me an error. init.lua:6: attempt to index field 'Owner' (a nil value) [code]effectdata:SetEntity(self.Owner)[/code]
[QUOTE=JamesFoil;23645954]Hm, I tried a little, but now it's giving me an error. init.lua:6: attempt to index field 'Owner' (a nil value) [code]effectdata:SetEntity(self.Owner)[/code][/QUOTE] self.Owner is the player you want to asign the effect to. Its just an example. [editline]11:46PM[/editline] [QUOTE=JamesFoil;23637769]Thanks for the help, but will you be willing to do me a favour and show me how to make this an Entity, like I said before. I am not so smart with the Lua language. :) Thanks alot.[/QUOTE] Sure, just show me the code of the entity you have now and ill implement it.
The only code I had in the init file, was the code you posted. Like before, I'm really new to lua, sorry.
..How the heck did i manage to accidentally post in another thread O.o... anyway ignore this.
Sorry, you need to Log In to post a reply to this thread.