Entity/GetAttachment

From Garry's Mod
Jump to: navigation, search
 Entity:GetAttachment( )

Contents

Description

Gets the orientation and position of the attachment by its ID, returns nothing if the attachment does not exist.

NOTE

The update rate of this function is limited by the setting of ENT.AutomaticFrameAdvance for Scripted Entities!

BUG

This will return improper values for viewmodels if used in GM:CalcView.

Issue Tracker: #1255

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