-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Ragdoll Functions #1678
Comments
Here's the code I'm currently using for my class, hope it helps! --@name Ragdoll Class
--@author
--@shared
Ragdoll = class("Ragdoll")
function Ragdoll:initialize(pos, ang, model, frozen)
local rag = prop.createRagdoll(model, frozen)
for k = 0, rag:getPhysicsObjectCount() - 1 do
local phys = rag:getPhysicsObjectNum(k)
local bone_pos, bone_ang = phys:getPos(), phys:getAngles()
local bone_p, bone_a = worldToLocal(bone_pos, bone_ang, Vector(), ang)
phys:setAngles(bone_a)
phys:setPos(pos + bone_p)
end
self.rag = rag
end
if SERVER then
local r = Ragdoll:new(chip():getPos(), Angle(0,0,0), "models/breen.mdl", true)
end |
I will add the setPos() and setAngles() in a bit if you need them, although that code above should be enough to help. |
I think most use cases don't want to spawn the ragdoll in a default pose, so it doesn't make much sense to have input pos/ang for default pose. |
I guess so, but the alternative is only spawning at Vector(0,0,0) and having to manually position each bone with the code above. I get what you're saying though. |
Maybe a helper function that takes input pos/ang/animation-pose could be added that does this. Like |
That could work but what would |
A table of positions and angles for bones or just angles? |
An animation sequence name maybe, if possible. |
ooh good idea! but I've had many problems with sequences and animations in Gmod so I bet it's gonna be weird getting that to work properly. |
Either that or it should just retain all the relative bone angles and positions |
what do you mean by "it should just retain all the relative bone angles and positions"? |
setting position would basically translate every bone. |
ah I see. |
Could we at least be able to set the ragdoll's position and angle without having to calculate the positions and angles manually for each bone? If you want I can provide code I've made in Starfall to help! It's part of my own ragdoll class I'm making (because of this issue)
I hope I don't need to structure this issue in any specific way like e2
The text was updated successfully, but these errors were encountered: