constraint.Muscle

From GMod Wiki

Revision as of 05:40, 2 March 2010 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax constraint.Muscle( Player pl, Entity Ent1, Entity Ent2, Number Bone1, Number Bone2, Vector LPos1, Vector LPos2, Number Length1, Number Length2, Number width, Number key, Number fixed, Number period, Number amplitude )
Where is this used?
Description:
Creates a muscle constraint.
Returns: Entity constraint, Entity rope, Entity controller, Entity slider
Part of Library: constraint
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Constraint.Muscle]Constraint.Muscle [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Example

DescriptionTaken from the Muscle tool in toolgun.
Used onNewerServer.png
Code
// Get client's CVars
local width			= self:GetClientNumber( "width", 3 )
local bind			= self:GetClientNumber( "group", 1 )
local AddLength		= self:GetClientNumber( "addlength", 0 )
local fixed			= self:GetClientNumber( "fixed", 1 )
local period		= self:GetClientNumber( "period", 1 )
 
// If AddLength is 0 then what's the point.
if ( AddLength == 0 ) then
	self:ClearObjects()
	return true 
end
 
if ( period <= 0 ) then period = 0.1 end
 
AddLength = math.Clamp( AddLength, -1000, 1000 )
 
// Get information we're about to use
local Ent1,  Ent2  = self:GetEnt(1),	 self:GetEnt(2)
local Bone1, Bone2 = self:GetBone(1),	 self:GetBone(2)
local LPos1, LPos2 = self:GetLocalPos(1),self:GetLocalPos(2)
local WPos1, WPos2 = self:GetPos(1),     self:GetPos(2)
 
local Length1 = (WPos1 - WPos2):Length()
local Length2 = Length1 + AddLength	
 
local amp = Length2 - Length1
 
local constraint,rope,controller,slider = constraint.Muscle( self:GetOwner(), Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, Length1, Length2, width, bind, fixed, period, amp )
 
OutputN/A

Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox