Skip to content
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

Open
Mikey-Mikey opened this issue Mar 17, 2024 · 13 comments
Open

More Ragdoll Functions #1678

Mikey-Mikey opened this issue Mar 17, 2024 · 13 comments
Labels

Comments

@Mikey-Mikey
Copy link

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

@Mikey-Mikey
Copy link
Author

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

@Mikey-Mikey
Copy link
Author

I will add the setPos() and setAngles() in a bit if you need them, although that code above should be enough to help.

@thegrb93
Copy link
Owner

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.

@Mikey-Mikey
Copy link
Author

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.

@thegrb93
Copy link
Owner

Maybe a helper function that takes input pos/ang/animation-pose could be added that does this. Like prop.setRagdollPose(ragdoll, pos, ang, animation_pose)

@Mikey-Mikey
Copy link
Author

That could work but what would animation_pose be?

@Mikey-Mikey
Copy link
Author

A table of positions and angles for bones or just angles?

@thegrb93
Copy link
Owner

An animation sequence name maybe, if possible.

@Mikey-Mikey
Copy link
Author

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.

@thegrb93
Copy link
Owner

thegrb93 commented Mar 19, 2024

Either that or it should just retain all the relative bone angles and positions

@Mikey-Mikey
Copy link
Author

what do you mean by "it should just retain all the relative bone angles and positions"?

@thegrb93
Copy link
Owner

setting position would basically translate every bone.

@Mikey-Mikey
Copy link
Author

ah I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants