• Shooting an effect from a weapon.
    3 replies, posted
I'm trying to make a smoke like effect come from my weapon, but I'm not sure about a few things. How would I make it come from the weapon, and not my head? How would I actually get it to fire forward? Right now it fires behind me at odd angles. How would I make it look good in both third person and first person? Currently this is my effect script [lua] function EFFECT:Init(data) local pos = data:GetOrigin() local dir = data:GetAngle() local emitter = ParticleEmitter(pos) for i=1, 2 do local X = math.Rand(-2, 2) local Y = math.Rand(-2, 2) local ppos = pos + Vector(X, Y, 0) local spray = emitter:Add("particle/particle_smokegrenade", ppos) if (spray) then spray:SetVelocity(dir*2) spray:SetLifeTime(0) spray:SetDieTime(math.Rand(0.5,1.5)) local color = math.Rand(220,250) spray:SetColor(color, color, color) spray:SetStartAlpha(math.Rand(190,200)) spray:SetEndAlpha(0) spray:SetStartSize(math.Rand(1,4)) spray:SetEndSize(math.Rand(4,8)) spray:SetRoll(math.Rand(0,360)) spray:SetRollDelta(math.Rand(-4,4)) local grav = math.Rand(-1,1) spray:SetGravity(Vector(grav, grav, grav)) spray:SetAirResistance(math.Rand(0,10)) spray:SetCollide(true) spray:SetBounce(0.5) end end emitter:Finish() end function EFFECT:Think() return false end function EFFECT:Render() end[/lua] and this is in SWEP:PrimaryAttack() [lua]local ply = self:GetOwner() local ED = EffectData() ED:SetOrigin(ply:GetShootPos()) ED:SetAngle(ply:GetAimVector()) util.Effect("effect_bugspray",ED)[/lua]
[code]local ply = self:GetOwner()[/code] should be [code]local ply = self.Owner[/code]
That doesn't fix any problem I had, but thank you, I will change it.
I still can't figure this out, anyone know how I'd do this? [highlight](User was banned for this post ("Bump bumpity bump" - mahalis))[/highlight]
Sorry, you need to Log In to post a reply to this thread.