constraint.Weld

From GMod Wiki

Revision as of 00:58, 8 August 2010 by Ultinine (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax constraint.Weld( Entity Ent1, Entity Ent2, Number Bone1, Number Bone2, Number forcelimit, Boolean nocollide_until_break )
Where is this used?
Description:
Creates a weld constraint.
Returns: Entity constraint
Part of Library: constraint
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Constraint.Weld]Constraint.Weld [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionSpawns a manhack and welds it to whatever the player is looking at. This is like Garry's Manhack gun.
Used onNewerServer.png
Code
local ply = self.Owner
local tr = ply:GetEyeTrace() --Get an eye trace
local ent = tr.Entity --Get the entity hit by the eye trace, if anything
if !ent then return end --Make sure we actually hit something!!!
local hax = ents.Create("npc_manhack") --Create the manhack
hax:SetAngles(ply:EyeAngles()) --Set the angles to the player's
hax:SetPos(tr.HitPos) --Set the right position.
hax:Spawn() --Spawn the manhack
constraint.Weld(ent,hax,tr.PhysicsBone,0,0,true) --And weld the manhack to the entity
OutputSpawns a manhack and welds it to whatever the player is looking at.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox