• Question: Is there any method to weld lua particle to Clientside Entity?
    21 replies, posted
Is it possible? Let's figure that out together.
Uhhh, what do you mean? Can't you just create the particles from the position of your clientside entity?
[QUOTE=Robotboy655;41029153]Uhhh, what do you mean? Can't you just create the particles from the position of your clientside entity?[/QUOTE] Hes talking about a consistant control point follower, Atleast that's what OBP's take it as.
If you're talking about emitters created using [url=http://wiki.garrysmod.com/page/Global/ParticleEmitter]ParticleEmitter[/url], here's an easy way to do it. Declare this function somewhere: [lua]local META = FindMetaTable("CLuaEmitter") if not META then return end function META:DrawAt(pos, ang, fov) local pos, ang = WorldToLocal(EyePos(), EyeAngles(), pos, ang) cam.Start3D(pos, ang, fov) self:Draw() cam.End3D() end[/lua] Then instead of creating your particle emitter at the desired position, create it at 0, 0, 0 and then call SetNoDraw(true) on it so it doesn't automatically render. Then, whenever you need to render it (in your scripted effect's Render hook, or maybe in your scripted entity's DrawTranslucent hook), just call its DrawAt function with the desired position and angles. FOV argument is optional, I use it for drawing muzzleflashes on viewmodels and such.
He doesn't talk about OB particles, does he?
[QUOTE=Robotboy655;41029952]He doesn't talk about OB particles, does he?[/QUOTE] No, I'm just merely stating what OBPCF's reference the function as.
I'm using CLuaParticles for gun effects. I know that's funny but I'm using PAC3. There was no choice :(..
[QUOTE=rebel1324;41030303]I'm using CLuaParticles for gun effects. I know that's funny but I'm using PAC3. There was no choice :(..[/QUOTE] Theres always a choice, You just gotta know how to work around that subject and what you want to be done. OBPCF's can be used for practically anything.
[QUOTE=Magenta;41030369]Theres always a choice, You just gotta know how to work around that subject and what you want to be done. OBPCF's can be used for practically anything.[/QUOTE] Can it be scaled by putting some parameters? vid: [media]http://www.youtube.com/watch?v=jaBcUvnm_zg[/media]
[QUOTE=rebel1324;41030450]Can it be scaled by putting some parameters? vid: [media]http://www.youtube.com/watch?v=jaBcUvnm_zg[/media][/QUOTE] Recreating the videos particles in OBPCF's would take a couple of seconds.
[QUOTE=Magenta;41030529]Recreating the videos particles in OBPCF's would take a couple of seconds.[/QUOTE] Welp... After done with skills and things, I'll give it a shot. But I believe there is a way to attach lua particles to some entity.
Eventually you could just push a model matrix.
[QUOTE=Wizard of Ass;41030739]Eventually you could just push a model matrix.[/QUOTE] ? What for?
Disable the default emitter drawing. Before drawing it manually, push a matrix with the position and rotation of the player. Pop the matrix after drawing the emitter. That might work, not too sure though.
[QUOTE=rebel1324;41030545]Welp... After done with skills and things, I'll give it a shot. But I believe there is a way to attach lua particles to some entity.[/QUOTE] Yeah I just told you how to do that. You might want to read my post. This one: [QUOTE=_Kilburn;41029930]If you're talking about emitters created using [url=http://wiki.garrysmod.com/page/Global/ParticleEmitter]ParticleEmitter[/url], here's an easy way to do it. Declare this function somewhere: [lua]local META = FindMetaTable("CLuaEmitter") if not META then return end function META:DrawAt(pos, ang, fov) local pos, ang = WorldToLocal(EyePos(), EyeAngles(), pos, ang) cam.Start3D(pos, ang, fov) self:Draw() cam.End3D() end[/lua] Then instead of creating your particle emitter at the desired position, create it at 0, 0, 0 and then call SetNoDraw(true) on it so it doesn't automatically render. Then, whenever you need to render it (in your scripted effect's Render hook, or maybe in your scripted entity's DrawTranslucent hook), just call its DrawAt function with the desired position and angles. FOV argument is optional, I use it for drawing muzzleflashes on viewmodels and such.[/QUOTE] It allows me to do things like this: [media]http://www.youtube.com/watch?v=S4j77Gc2HiQ[/media] I believe that's what you're looking for?
Hell, Thanks. I found another way to do that, but that needs another tricky hacks. Thanks a lot! [lua] function EFFECT:Render() if CurTime() + 0.06 > CurTime() then return end print(1) local ply = self.WeaponEnt:GetOwner() if not ply:IsValid() then return end local pos, ang = ply:GetPACPartPosAng( pac_luamodel[ GAMEMODE.PapperDollEnts[ply:EntIndex()]["slot_primaryweapon"] ], "muzzleflash") self.Emitter:DrawAt(pos, ang) end [/lua] Just like this?
[QUOTE=rebel1324;41040755]Hell, Thanks. I found another way to do that, but that needs another tricky hacks. Thanks a lot! [lua] function EFFECT:Render() if CurTime() + 0.06 > CurTime() then return end print(1) local ply = self.WeaponEnt:GetOwner() if not ply:IsValid() then return end local pos, ang = ply:GetPACPartPosAng( pac_luamodel[ GAMEMODE.PapperDollEnts[ply:EntIndex()]["slot_primaryweapon"] ], "muzzleflash") self.Emitter:DrawAt(pos, ang) end [/lua] Just like this?[/QUOTE] Yeah looks like it would work.
[QUOTE=_Kilburn;41042799]Yeah looks like it would work.[/QUOTE] Hmm... It seems not working. I think I'm doing it wrong. can you give me some references?
[QUOTE=rebel1324;41043389]Hmm... It seems not working. I think I'm doing it wrong. can you give me some references?[/QUOTE] Can I see your full code?
[url]http://pastebin.com/SMebE4Pk[/url] : Muzzle Effect Muzzle effect is called with util.Effect().
[QUOTE=rebel1324;41043677][url]http://pastebin.com/SMebE4Pk[/url] : Muzzle Effect Muzzle effect is called with util.Effect().[/QUOTE] You're creating the particle emitter and its particles at self.Origin, that's why. DrawAt uses the position of the emitter as a relative position, that means you should create the emitter at vector_origin, or Vector(0, 0, 0) if you want it to be centered on your entity. Same for the particles you're adding.
[QUOTE=_Kilburn;41047000]You're creating the particle emitter and its particles at self.Origin, that's why. DrawAt uses the position of the emitter as a relative position, that means you should create the emitter at vector_origin, or Vector(0, 0, 0) if you want it to be centered on your entity. Same for the particles you're adding.[/QUOTE] Can I add you? I want to learn more things and I'll ask you about this problem later. Sunday is pretty busy day :|
Sorry, you need to Log In to post a reply to this thread.