Entity/SetBoneMatrix

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

Contents

Description

Sets the bone matrix of given bone to given matrix. See also Entity:GetBoneMatrix.

Despite existing serverside, it does nothing.

Arguments

number boneid

The ID of the bone

Arguments

VMatrix matrix

The matrix to set.

Examples

Example

Example usage of the function.

Aim at an NPC and enter "bones_cl" into your console.

if ( CLIENT ) then
	concommand.Add( "bones_cl", function( ply )
		local ent = ply:GetEyeTrace().Entity
		if ( !IsValid( ent ) ) then return end

		ent:AddCallback( "BuildBonePositions", function( ent, numbones )
			for i = 0, numbones - 1 do
				local mat = ent:GetBoneMatrix( i )
				if ( !mat ) then continue end

				local scale = mat:GetScale()
				mat:Scale( Vector( 1, 1, 1 ) * 0.5 )
				ent:SetBoneMatrix( i, mat )
			end
		end )
	end )
end


Personal tools
Navigation