SetBonePosition: Bone is unwriteable

I wonder what may be the cause of this error. It only seems to occure when I try to set the bone position in certain map locations. The code that causes that error (It doesn’t look like a Lua error, more like a warning.):

[lua]
local bonestomove = {
“ValveBiped.Bip01_Pelvis”,
“ValveBiped.Bip01_Spine”,
“ValveBiped.Bip01_Spine1”,
“ValveBiped.Bip01_Spine2”,
“ValveBiped.Bip01_Spine4”,
“ValveBiped.Bip01_R_Clavicle”,
“ValveBiped.Bip01_R_UpperArm”,
“ValveBiped.Bip01_R_Forearm”,
“ValveBiped.Bip01_R_Hand”,
“ValveBiped.Bip01_L_Clavicle”,
“ValveBiped.Bip01_L_UpperArm”,
“ValveBiped.Bip01_L_Forearm”,
“ValveBiped.Bip01_L_Hand”,
“ValveBiped.Bip01_R_Thigh”,
“ValveBiped.Bip01_R_Calf”,
“ValveBiped.Bip01_R_Foot”,
“ValveBiped.Bip01_L_Thigh”,
“ValveBiped.Bip01_L_Calf”,
“ValveBiped.Bip01_L_Foot”,
“ValveBiped.Bip01_Head1”,
}

function ENT:Draw ()
self:DrawModel ()
end

function ENT:CalcBonePositions (ply)
for k, v in pairs (bonestomove) do
local bone1 = ply:LookupBone (v)
local bone2 = self:LookupBone (v)
local pos, ang = ply:GetBonePosition (bone1)
self:SetBonePosition (bone2, pos, ang)
end
end

function ENT:BuildBonePositions (numbones, numphysbones)
local ply = Entity(1)
self:CalcBonePositions (ply)
end [/lua]

The side effects of this error are model polygons stretches almost all over the map.

I think you may have forgotten a bone. Also, I would recommend using the source bonemerge for the best performance. [lua]self:AddEffects( EF_BONEMERGE | EF_BONEMERGE_FASTCULL | EF_PARENT_ANIMATES )[/lua]

Could you kindly explain as to how am I supposed to use this?

[editline]24th May 2011[/editline]

I would deal with that I have forgotten some of the bones, but the effect of stretched polygons only occures in certain areas of the map (Likely close to the origin of the map, i.e x/y/z near 0/0/0, also some other areas.). And it also moves alongside with the main entity, so it’s just like if they were translated to a wrong position.

[editline]24th May 2011[/editline]

I found out that it actually stretches the bones if the distance from the render point and the entity itself is like medium (not too long and not too short). So parenting that entity to the local player fixed the problem (The distance is always 0, but bones are where they should be). I had this problem because I used cameras… lol…

Also, adding the said effects have also seemed to fix the problem with the error itself. So, thanks.