Revision Difference
Entity:GetAttachment#515715
<function name="GetAttachment" parent="Entity" type="classfunc">⤶
<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 <page>Scripted Entities</page>!</note>⤶
⤶
<bug issue="1255">This will return improper values for viewmodels if used in <page>GM:CalcView</page>.</bug>⤶
</description>⤶
<realm>Shared</realm>⤶
<args>⤶
<arg name="attachmentId" type="number">The internal ID of the attachment.</arg>⤶
</args>⤶
<rets>⤶
<ret name="" type="table">The angle and position of the attachment. See the <page>AngPos</page>. Most notably, the table contains the keys "Ang" and "Pos".</ret>⤶
</rets>⤶
</function>⤶
⤶
<example>⤶
<description>Grabs the muzzle position of a player's view model</description>⤶
<code>⤶
local vm = ply:GetViewModel()⤶
local obj = vm:LookupAttachment( "muzzle" )⤶
local muzzlepos = vm:GetAttachment( obj )⤶
</code>⤶
⤶
</example>