Copying existing ragdoll positions onto a new ragdoll?
1 replies, posted
Hi guys,
so for a while I've been trying to work out how to create client ragdolls with the same bone positions as another ragdoll, however I am really rather unsure how to do this given every one of my attempts has failed.
I have a list of modifiable bones as follows:
[lua]local skeleton = {
"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"
}[/lua]
and I then store the positions of these bones in a table so I can use this table to set the bone positions of another ragdoll later, similar to this:
[lua]
local bones = {}
for i, bone in pairs(skeleton) do
local boneTable = {}
local boneIndex = plr:LookupBone(bone)
boneTable.index = boneIndex
boneTable.pos = plr:GetManipulateBonePosition(boneIndex)
boneTable.ang = plr:GetManipulateBoneAngles(boneIndex)
table.insert(bones,boneTable)
end
[/lua]
SetBonePosition unfortunately seems extremely buggy and I have been unable to get it to work at all, giving me all this "bone unwritable" rubbish.
This simply makes the skeleton T pose, presumably because the bones have not been "manipulated" but this function is the only way I am able to reliably change the bone positions.
Is there some function I've missed that will let me get the actual bone positions for use with ManipulateBonePositions/Angles?
Take a look at TTT, corpse.lua on the Create segment. It shows how to copy exact bones from the player to entity to give the appearance of player falling over.
Sorry, you need to Log In to post a reply to this thread.