• Particle Tomfoolery
    1 replies, posted
Since there's a lot of weirdness surrounding particle effects, I've gotta ask for help. I want TF2 particle tracers. Tracers look like garbage if they aren't parented to the weapon. ParticleTracerEx( ) starts the attachment of an entity, but isn't parented, so it's out of the question. Entity:CreateParticleEffect( ) takes control points, but you can't create points at origins - they have to be parented to something. So, how do I create that "something"? I was assuming I could create a couple client-side models, but I have no idea how to work with them, and I need them to be consistently attached to the player when the weapon is out. I don't know how to deal with the localization of that and how to refer to it. [editline]20th May 2015[/editline] [code] function SWEP:DoImpactEffect( tr, nDamageType ) if CLIENT then if self.cM then for k, v in pairs( self.cM ) do v:Remove( ) end end self.cM = { ClientsideModel( "models/alyx_EmpTool_prop.mdl" ), ClientsideModel( "models/alyx_EmpTool_prop.mdl" ) } self.cM[ 1 ]:SetPos( self:MuzzlePosition( )[2] ) self.cM[ 1 ]:SetAngles( self:MuzzlePosition( )[3] ) self.cM[ 1 ]:SetParent( self.Owner:GetViewModel( ) ) self.cM[ 1 ]:SetPos( self:MuzzlePosition( )[2] ) self.cM[ 1 ]:SetAngles( self:MuzzlePosition( )[3] ) self.cM[ 2 ]:SetPos( tr.HitPos + tr.HitNormal ) self.cM[ 2 ]:SetAngles( self:MuzzlePosition( )[3] ) local cP = { { [ "entity" ] = self.cM[ 1 ], [ "attachtype" ] = PATTACH_POINT_FOLLOW }, { [ "entity" ] = self.cM[ 2 ], [ "attachtype" ] = PATTACH_ABSORIGIN_FOLLOW } } for k, v in pairs( self.Primary.Tracer.Particles ) do if v == "muzzle" then ParticleEffect( k, self:MuzzlePosition( )[2], self.Owner:EyeAngles( ), self.Owner ) elseif v == "tracer" then -- util.ParticleTracerEx( k, Vector( 0, 0, 0 ), tr.HitPos + tr.HitNormal, false, self.Owner:GetViewModel( ):EntIndex( ), self:MuzzlePosition( )[1] ) self.cM[ 1 ]:CreateParticleEffect( k, cP[ 1 ], cP[ 2 ] ) end end end if ( tr.HitSky ) then return end local effectdata = EffectData() effectdata:SetOrigin( tr.HitPos + tr.HitNormal ) effectdata:SetNormal( tr.HitNormal ) util.Effect( "ar2impact", effectdata ) end[/code] This is the closest I've gotten. Too bad there's no better way to interact with control points and particle systems with GLua, because this goes straight from my muzzle to Vector(0, 0, 0). [editline]20th May 2015[/editline] [img]https://dl.dropboxusercontent.com/u/965202/ShareX/2015/05/Garry%27s_Mod_2015-05-20_06-41-09.jpg[/img] Here you can see it's blatantly going upwards towards ( 0, 0, 0 )
The problem is this: [code]self.cM[ 1 ]:CreateParticleEffect( k, cP[ 1 ], cP[ 2 ] )[/code] You've got cP[ 1 ] as the second arg and cP[ 2 ] as the third arg. There are only two args to that function, and the second one is supposed to be a table containing all the control points: [code]self.cM[ 1 ]:CreateParticleEffect( k, { cP[ 1 ], cP[ 2 ] } ) or just self.cM[ 1 ]:CreateParticleEffect( k, cP )[/code] Also, you actually can send control points to vector positions by giving their subtable an entry named "position": [code]{ [ "position" ] = tr.HitPos }[/code] You can't set the angle, though, so you might not want to use those depending on the effect you're using.
Sorry, you need to Log In to post a reply to this thread.