• Decal attaches to player instead of appearing on the ground?
    2 replies, posted
Basically, I'm trying to make a swep that shoots a decal to any surface as part of a secondary attack. The part of the code that I'm having trouble with is in bold. [QUOTE]--/SECONDARY ATTACK function SWEP:SecondaryAttack() local trace = self.Owner:GetEyeTrace() trace.endpos = self.Owner:GetPos() + (self.Owner:GetAimVector() * dist) if trace.HitNonWorld then util.BlastDamage(self.Owner, self.Owner, trace.HitPos, 1, 25) end self.Owner:SetPos(self.Owner:GetEyeTrace().HitPos) self.Weapon:EmitSound("weapons/tele/teleport.wav") self.Weapon:SetNextSecondaryFire(CurTime() + 0.2) self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ) [B]local Pos1 = self.Owner:GetEyeTrace().HitPos local Pos2 = self.Owner:GetAimVector() util.Decal("blood", Pos1, Pos2)[/B] end[/QUOTE] It was my understanding that the bold code would shoot a decal to my hitposition, but the decal attaches to my playermodel instead for some reason. [URL="http://i47.tinypic.com/160r4hy.jpg"]http://i47.tinypic.com/160r4hy.jpg[/URL] Any idea on what I'm doing wrong? I'm quite new to Gmod Lua so this could just be a foolish mistake. Edit: Hurr, I forgot about the Help and Support forum. This thread will probably be moved/locked soon.
try this [lua] local pos1 = trace.HitPos + trace.HitNormal -- you have self.Owner:GetEyeTrace() localized as trace already, so theres no point doing GetEyeTrace() a second time local pos2 = trace.HitPos - trace.HitNormal [/lua] and one question: are you making a melee weapon?
[QUOTE=comet1337;37814935]try this [lua] local pos1 = trace.HitPos + trace.HitNormal -- you have self.Owner:GetEyeTrace() localized as trace already, so theres no point doing GetEyeTrace() a second time local pos2 = trace.HitPos - trace.HitNormal [/lua] and one question: are you making a melee weapon?[/QUOTE] That was the code I used initially, it did the same thing as the code in the OP for some reason so I decided to fiddle around with it a bit. Perhaps the function was changed at some point. Thanks for the response though. And yes, it's a melee weapon.
Sorry, you need to Log In to post a reply to this thread.