• Getting hl2mp_ragdoll's position and angle
    8 replies, posted
Found absolutely nothing on this. I have to create a hl2mp_ragdoll but SetPos and SetAngles don't work on it so when someone dies, the ragdoll just spawns at the map's origin. What can I do?
Try setting the position and angles of the ragdoll's physics objects.
So like this?     local Ragdoll = ents.Create( "hl2mp_ragdoll" )     Ragdoll:Spawn();     Ragdoll:SetModel(player:GetModel());     for ID = 0, Ragdoll:GetPhysicsObjectCount()-1 do         local PhysBone = Ragdoll:GetPhysicsObjectNum( ID )         if ( PhysBone:IsValid() ) then             local Pos, Ang = player:GetBonePosition( Ragdoll:TranslatePhysBoneToBone( ID ) )             PhysBone:SetPos( Pos )             PhysBone:SetAngles( Ang )             PhysBone:AddVelocity( PlyVel )         end     end Or am I dumb?
That looks about right except ragdolls and player models aren't guaranteed to have the same bones or physics objects, so you might get some funky behaviour or errors with some models.
Tested, ragdolls still spawn at the origin of the map for some reason :-/
You probably need to set the model before spawning the ragdoll so the proper physics is initialized.
Still doesn't seem to do anything. I've played with the order but no dice. GMod Wikia hasn't helped here either.     local Ragdoll = ents.Create( "hl2mp_ragdoll" )     Ragdoll:SetModel(player:GetModel());     Ragdoll:Spawn();     for ID = 0, Ragdoll:GetPhysicsObjectCount()-1 do         local PhysBone = Ragdoll:GetPhysicsObjectNum( ID )         if ( PhysBone:IsValid() ) then             local Pos, Ang = player:GetBonePosition( Ragdoll:TranslatePhysBoneToBone( ID ) )             PhysBone:SetPos( Pos )             PhysBone:SetAngles( Ang )             PhysBone:AddVelocity( PlyVel )         end     end
This might be why. I can't get the ragdoll to move with Entity/SetNetworkOrigin, Entity/SetPos, or Entity/SetLocalPos; I'll keep playing around with it.
Well damn. What I tried to do was get clientside player ragdolls to stay - since the default ragdoll doesn't seem to do that, I had to spawn one. Either way, thanks for your help!
Sorry, you need to Log In to post a reply to this thread.