Final explanation of what I’m doing:
First I pose a ragdoll in sandbox. I spawn a prop and place it somewhere alongside its body.
[img_thumb]http://www.mr-green.nl/clavus/bone.jpg[/img_thumb]
(click to view)
Using my own bone info tool, I select a ragdoll bone and the prop.
It grabs the ragdoll bone angles and position using Entity.GetBonePosition( )
It grabs the props rotation using GetAngles( )
It then calculates the relative position and the relative angle (<- where I think the problem is) and prints this to console as a lua table. Example:
{ model = "models//gibs/hgibs.mdl", bone = "ValveBiped.Bip01_Head1", pos = Vector(0.66467, -0.94526, 2.07958), ang = Angle(80.25862, -194.19928, 118.75885) },
Now in my gamemode I use this table to spawn a sent that puts the ‘ang’ value in NetworkedAngle “angles”.
My current clientside code of this sent:
[lua]
function ENT:Draw()
if (LocalPlayer() == self:GetOwner()) then return end
local ply = self:GetOwner():GetRagdollEntity() or self:GetOwner()
local bone = ply:LookupBone(self:GetNWString("bone"))
if bone then
local position, angles = ply:GetBonePosition(bone)
local offset = self:GetNWVector("position")
local x = angles:Up() * offset.x
local y = angles:Right() * offset.y
local z = angles:Forward() * offset.z
local matrix = ply:GetBoneMatrix( bone )
matrix:Rotate( self:GetNWAngle("angles") )
local angles = matrix:GetAngle()
//local pitch = self:GetNWAngle("angles").p
//local yaw = self:GetNWAngle("angles").y
//local roll = self:GetNWAngle("angles").r
//angles:RotateAroundAxis(angles:Forward(), pitch)
//angles:RotateAroundAxis(angles:Right(), yaw)
//angles:RotateAroundAxis(angles:Up(), roll)
self:SetPos(position + x + y + z)
self:SetAngles(angles)
self:DrawModel()
end
end
[/lua]
Ingame, it draws like this:
[img_thumb]http://www.mr-green.nl/clavus/bone2.jpg[/img_thumb]
(click to view) (ignore the other two props sticking out of him)
THAT is my problem.