Ragdoll system: joint spesific ragdolling and more

I had abandoned the place file, but I recreated the issue,

The place file is here.
ragdolltest.rbxl (443.5 KB)

I don’t know if it’s an issue but the characters I have are R15 characters, sometimes with no HumanoidDescription, and sometimes they have a lot of accessories equipped to them.
The primary part is set to the humanoidrootpart and humanoid set to r15

1 Like

Thanks, the place file helped a lot.

The reason for the error was that my code assumed that only bodyparts have Attachments with “RigAttachment” in their names. So such an attachment in an accessory caused the error. I added a condition in assignRigAttachmentsToBodypartNodes for skipping rig attachments that are descendants of accessories.

I also fixed some other problems that I happened to find that are irrelevant to this problem (listed in the changelog).

Also, since the code for ragdolling the character and the initialization code are in different scripts in the test place and there’s nothing controlling which runs first, that sometimes causes a different error because other functions in RagdollSystem are not meant to be called before calling the initialization functions.

That’s excellent update! Thanks for the fix! Also, I understand the initialization setup must be done first. I will get back to this soon, I disabled my old ragdoll system and am hoping to upgrade to this one. :slight_smile:
I had a feeling it was due to the accessories, but that’s just how accessories work, you have a attachment inside of it that tells the humanoid api to attach the accessory offset from the existing attachment inside the bodypart. So that’s a good fix.

I just tested it and it works great! I’m about to implement it into my combat AIs. But one last question what does future support look like for bones? What are the obstacles for using bones?

I have no experience with using bones but I suppose it would be necessary to create invisible collision parts with rig attachments, create the physics constraints between these collision parts and find the correct bone for each rig attachment pair. And when a joint is in ragdoll state, the CFrame of the bone of that joint would be updated every frame using the CFrame of the joint’s rig attachment that is parented to the part lower in the animation hierarchy.

If a skinned character consists of multiple parts but not as many parts as there are animated joints, then I should probably support breaking joints that connect collision parts for two different skinned parts (and also disable whatever is keeping the skinned parts together and reparent the skinned parts) but throw an error if the user tries to break a joint between collision parts that are for the same skinned part.

The user would have to create the collision parts and their RigAttachments beforehand. Perhaps I would also require creating RigidConstraints or something between the RigAttachments to define which pairs of attachment belong together although that may be unnecessary as I could just use the similarity of WorldCFrames of rig attachments to figure out which of them are pairs as long as the rig attachment pairs are positioned in the same world position when RagdollStructure.createStructure is called.

My current code assumes that each pair of connected bodyparts has a Motor6D but if I add support for bones then I can’t make this assumption anymore, so many changes to the code would be needed. Unfortunately I’m not sure if I’ll add support for bones and even if I do, it most likely won’t be soon.

I would probably fork into something like SmartBone 2 - Simulated Physics and Collision solution for Bones - Resources / Community Resources - Developer Forum | Roblox
I’ll be taking a deeper diver into this module. It basically works with a meshpart, that has an attribute called Smartbone and an armature of bones inside the part. I think ragdolling would be a simple implementation since it is designed for physics. I’ve been considering a hair physics and cape physics solution using the templates provided by that resource.
I haven’t tested this module with these Motor 6D jointed animals but I understand that it should be compatible with custom Motor6D rigs. This module is a great contribution! Good work!
Am working on hair library currently, and maybe experimenting with ragdoll physics for bones with it later.

I’ve been trying to implement this into my game for a bit of fun, and its a bit of a challenge. For one, it seems that the system clones the entire character and makes the new one invisible, which is fine, except that I have some custom nametags that I can’t get off of the clones. Is there some way to filter these out of the clone?

Second, i’ve noticed that in the game the clones get a ForceField, which doesn’t happen in my testing place with the same exact scripts. Remembered I could just remove the ForceField duration on the spawns

The purpose of the clone is to be prevent the character from teleporting on other clients than the network owner when ragdolling (the original character still teleports but this is a visual fix). The teleporting happens because, for some reason, the physics of the character pause for a while on other clients when ragdolling. The clone is made visible when ragolling and it is moved during this physics pause and when the physics start working again, the clone is made invisible. There may be a better solution to the problem but I don’t know what that would be.

You can get rid of the clone entirely by setting doChoppinessFix to false in the settings of RagdollRootConstraint in character settings. Now that you mentioned this problem, I also added a ChoppinessFixCloneCreated event property to RagdollRootConstraint objects and a getRagdollConstraintsOfGivenType method to RagdollStructure objects so that it’s possible to easily modify the clone if you want to keep it. Here’s some example code.

local RagdollSystem = require(--[[Path to RagdollSystem package]].RagdollSystem)
local RagdollStructureCollections = RagdollSystem.RagdollStructureCollections 
local RagdollConstraintType = RagdollSystem.RagdollConstraintType

local ragdollStructure = RagdollStructureCollections.getRagdollStructureFromInstance(--[[character here]])
local rootConstraint = ragdollStructure:getRagdollConstraintsOfGivenType(RagdollConstraintType.builtInTypes.RagdollRootConstraint)[1]
local cloneCreatedConnection = rootConstraint.ChoppinessFixCloneCreated:Connect(function(rootConstraint, newClone)
	-- do modification
end)
1 Like