LEGITIMATELY impossible: World-space bone manipulation.

So I wanted to use ManipulateBonePosition to make a bone follow an entity. However, ManipulateBonePosition uses local coordinates rather than WS ones. I just thought “I’ll use WorldToLocal to convert the entity’s position relative to the bone’s default position!” So I tried this, and the bone didn’t line up! So then I figured that the orientation of the bone’s coordinate system is relative to it’s parent bone rather than itself. So I tried this, and it was still off! So then I thought that maybe its orientation is relative to it’s nearest physbone rather than simply its parent bone. I tried this, and it was still off!

I then tried various combinations of bone positions and bone angles as the local system’s orientation, but none of them seemed to work.

What local system does ManipulateBonePosition use? How would I make a ManipulateBonePositionWS function?? Help!

TTT uses something similar to this to spawn a ragdoll in the exact same position as the player when they died:

self = target,from source
[lua]//
// TTT
//
function ENTITY:TransferBonePositions( _source )
for i = 0, ( self:GetPhysicsObjectCount( ) - 1 ) do
local _bone = self:GetPhysicsObjectNum( i )

	if ( IsValid( _bone ) ) then
		local _bonePos, _boneAng = _source:GetBonePosition( self:TranslatePhysBoneToBone( i ) )
		if ( _bonePos && _boneAng ) then
			_bone:SetPos( _bonePos )
			_bone:SetAngles( _boneAng )
		end

		_bone:SetVelocity( _source:GetVelocity( ) )
	end
end

end[/lua]

self = source, to target.
[lua]function ENTITY:TransferBonePositions( _target )
for i = 0, ( _target:GetPhysicsObjectCount( ) - 1 ) do
local _bone = _target:GetPhysicsObjectNum( i )

	if ( IsValid( _bone ) ) then
		local _bonePos, _boneAng = self:GetBonePosition( _target:TranslatePhysBoneToBone( i ) )
		if ( _bonePos && _boneAng ) then
			_bone:SetPos( _bonePos )
			_bone:SetAngles( _boneAng )
		end

		_bone:SetVelocity( self:GetVelocity( ) )
	end
end

end[/lua]

I cleaned it up, and turned it into a nice little useful function.

This may or may not help? It copies everything, including fingers if I recall correctly… Choose whichever function suites you best.

This only references physics bones, I can’t see where it would work on other bones.
What i’m trying to do is set the position of a non-physics bone using world space coordinates…