Ok.
My goal is to make a sledge hammer that when it hits an object it removes all of its constraints.
I already have a sledge hammer weapon base but I need to add the remove constraints.
The part of the code I’m focusing on is this:
-- function SWEP:Reload() --To do when reloading
-- end
function SWEP:Think() -- Called every frame
end
function SWEP:Initialize()
util.PrecacheSound("")
end
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + .4)
local trace = self.Owner:GetEyeTrace()
if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
bullet = {}
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0, 0, 0)
bullet.Tracer = 0
bullet.Force = 1
bullet.Damage = 25
self.Owner:FireBullets(bullet)
self.Weapon:EmitSound("")
else
self.Weapon:EmitSound("" .. math.random( 1, 4 ) .. ".wav")
self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
end
end
I want to add the remove constraints to the primary attack and secondary but I assume that adding it to the primary is the same as secondary.
I know that the code for remove constraints is:
constraint.RemoveConstraints
But what I don’t know is where to add it to the current code and if necessary tell it that it happens to the object that is hit by the weapon (in case that is required).
(User was banned for this post ("Wrong section / undescriptive thread title" - mahalis))