• How to create a tracer from the gun?
    8 replies, posted
Hi, I would like to create a simple tracer from the gun without shooting the bullet. I created a physical bullet that takes time to hit the target, but I can't seem to put a tracer that follows it. For example, on a normal bullet function, they include a tracer in it. I would like to do the same thing and create a similar effect. [lua] local bullet = {} bullet.Num = num_bullets bullet.Src = self.Owner:GetShootPos() // Source bullet.Dir = self.Owner:GetAimVector() // Dir of bullet bullet.Spread = Vector(aimcone, aimcone, 0) // Aim Cone bullet.Tracer = 1 // Show a tracer on every x bullets bullet.TracerName = Tracer bullet.Force = damage * 0.5 // Amount of force to give to phys objects bullet.Damage = damage self.Owner:FireBullets(bullet) [/lua] If anyone happens to know how it's done, please help me! Worshipper.
You can use this in the SWEP:Think [code] trace = self.Owner:GetEyeTrace() [/code] Not sure though, might be a bit laggy
I want a tracer effect, not a simple eye trace. Thanks anyway!
[lua] local effectdata = EffectData() effectdata:SetOrigin( tr.HitPos ) effectdata:SetStart( self.Owner:GetShootPos() ) effectdata:SetAttachment( 1 ) effectdata:SetEntity( self.Weapon ) util.Effect( (tracer effect here), effectdata )[/lua] Try This . For tracer effects look here : [url]http://wiki.garrysmod.com/?title=Util.Effect[/url]
But I have a little problem. If I want the same spread for the tracer (because I don't want a straight line), how am I supposed to match it? Thanks for the help. [lua] /*--------------------------------------------------------- Shoot the dawn bullet! ---------------------------------------------------------*/ // Entity bullet made by Teta_Bonita function SWEP:ShootBullet(dmg, speed, spread, spray, sprayvec, numbul, accel, mask, filter) numbul = numbul or 1 accel = accel or Vector(0, 0, -600) // Gravity mask = mask or MASK_SHOT // Tracemask if (SERVER) then for i = 1, numbul do local eBullet = ents.Create("ent_op_bullet") local Velocity = speed * (self.Owner:GetAimVector() + VectorRand() * spread + 0.04 * spray * sprayvec:GetNormalized()):GetNormalized() eBullet:SetPos(self.Owner:GetShootPos()) eBullet:SetVar("Velocity", Velocity) eBullet:SetVar("Acceleration", accel) local tBullet = {} // This is the bullet our bullet SENT will be firing when it hits something. Everything except force and damage is determined by the bullet SENT tBullet.Force = 0.15 * dmg tBullet.Damage = dmg local tTrace = {} // This is the trace the bullet SENT uses to see if it has hit something tTrace.filter = filter or {self.Owner, eBullet} tTrace.mask = mask eBullet:SetVar("Bullet", tBullet) eBullet:SetVar("Trace", tTrace) eBullet:SetVar("Owner", self.Owner) eBullet:SetVar("Weapon", self.Weapon) eBullet:Spawn() local tr = util.GetPlayerTrace(self.Owner) local trace = util.TraceLine(tr) local effectdata = EffectData() effectdata:SetOrigin(trace.HitPos) effectdata:SetStart(self.Owner:GetShootPos()) effectdata:SetAttachment(1) effectdata:SetEntity(self.Weapon) util.Effect("ToolTracer", effectdata) end end end [/lua]
Well, if it's an actual entity, not a point being iterated through space, then I would parent the effect to it. I know that another dynamic bullet system just did traces as fast as it could, which were serverside and therefore the clients' couldn't know where the bullet was and an effect could not be generated by it. But yeah, I'd definitely try to tie the tracer to the bullet and not the gun, you know?
I found the way to make tracer , but it's bullet effect , gonna give you my code , wait EDIT : Nvm
You gonna make V4? [highlight](User was banned for this post ("Irrelevant bump (this is what PMs are for)" - mahalis))[/highlight]
[QUOTE=xxXAcePilotXxx;22669828]You gonna make V4?[/QUOTE] Maybe you should stop whining and be patient
Sorry, you need to Log In to post a reply to this thread.