Entity/GetAttachment

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Making it easier for future viewers. They'll be looking for this too.)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=GetAttachment
 
|Parent=Entity
 
 
|Description=Gets the orientation and position of the attachment by its ID.
 
|Description=Gets the orientation and position of the attachment by its ID.
 
|Realm=Shared
 
|Realm=Shared
Line 16: Line 14:
 
}}
 
}}
 
{{Example
 
{{Example
| Description = Grabs the muzzle position of a player's view model
+
|Description=Grabs the muzzle position of a player's view model
| Code =  
+
|Code=
local viewm = ply:GetViewModel()
+
local vm = ply:GetViewModel()
local obj = viewm:LookupAttachment( "muzzle" )
+
local obj = vm:LookupAttachment( "muzzle" )
 
local muzzlepos = vm:GetAttachment( obj )
 
local muzzlepos = vm:GetAttachment( obj )
 
}}
 
}}

Revision as of 10:18, 15 May 2016

 Entity:GetAttachment( )

Contents

Description

Gets the orientation and position of the attachment by its ID.

Arguments

number attachmentId

The internal ID of the attachment.

Returns

table

The angle and position of the attachment. See the AngPos structure. Most notably, the table contains the keys "Ang" and "Pos".

Examples

Example

Grabs the muzzle position of a player's view model

local vm = ply:GetViewModel()
local obj = vm:LookupAttachment( "muzzle" )
local muzzlepos = vm:GetAttachment( obj )


Personal tools
Navigation