Ragdoll Body
Ragdoll body allows applying physical forces to bone-animated characters, such as inverse kinematics and procedural animation of a death sequence.
See also#
- BodyRagdoll class
- Fragment of the video tutorial on physics illustrating inverse kinematics of a Ragdoll body
Assigning a Ragdoll Body#
To assign a Ragdoll body to an object in UnigineEditor, perform the following steps:
- In the World Nodes window, select the Mesh Skinned object that you want to assign a Ragdoll body to.
-
Switch to the Physics tab in the Parameters tab and select Body -> RagDoll.
- Set the body name and proceed with creating a skeleton.
Creating a Skeleton#
Ragdoll body is requires a skeleton (or a rig), which is in fact a hierarchy of the character bones each represented by an Object Dummy with a Rigid body assigned. These bones are connected by joints that limit their movement relative to each other, creating a realistic look.
When the Ragdoll body is assigned to the Mesh Skinned object, all the bones are free, i.e. not united into a skeleton. Click the Create button to configure the Ragdoll bone generation parameters and automatically generate a skeleton.
Automatic generation is performed on the basis of the following parameters:
Total Mass |
Total mass of the Ragdoll will be automatically distributed among all the shapes that approximate bones. By distribution, the volume that the shape occupies is taken into account. If the mass is changed afterwards, masses of all the shapes are recalculated. And the opposite way, if shape mass is changed, the total mass is modified correspondingly. |
---|---|
Approximation Error |
The value that makes it possible to control the number of vertices in the resulting shape. Depending on the use case, the shape may be more or less detailed.
|
Volume Threshold |
When creating a Ragdoll, small bones (like finger bones, for example) are rarely simulated. They are too insignificant to change the motion of the whole object, as their mass and volume is not sufficient for that. Volume threshold allows to merge all small adjacent bones, the volume of which is too small, into one shape: |
Capsule Shape |
This setting defines the approximation shape to be used for bones:
If any other shape is required, approximation is to be done manually. Approximation with capsules and convex hulls
Notice
Remember that physical shapes don't need to reproduce the mesh precisely. Rough approximation provides physical interaction that is realistic and convincing enough. |
Body Hierarchy for Bones#
After the skeleton has been created, all the bones that participate in the physical body movement have rigid bodies and shapes and are marked as bound in the hierarchy. All the small bones not participating in physical body movement remain marked as free. If automatically generated shapes don't fit the object contours, they can be tuned manually till their approximation is satisfying enough.
The hierarchy of bodies and shapes that approximate bones may be saved into a *.node file and loaded from it. You can also remove the set hierarchy from the Ragdoll body and create it anew.
Manual Editing of the Skeleton#
It is also possible to edit or even create a skeleton manually. In this case you can use arbitrary shapes to approximate the skeleton bones.
To edit the automatically created skeleton, click the Save button and add the saved *.node file to the scene for editing.
To create a skeleton manually from scratch, follow these steps:
- Create a Node Dummy that will be a parent node for the future skeleton hierarchy.
- Add a Dummy object as a child node. Assign a Rigid body to it and name the body after the bone it will represent. After that, approximate the bone with any necessary shape.
- Create all Rigid bodies and shapes for the skeleton bones. Hierarchy is of no importance, only names of the bodies do — they should be the same as the names of the bones. If body names mismatch bone names, an error will occur.
- Export the parent node into the *.node file.
- Select the character and load this file for its Ragdoll body.
- Add and set up joints that connect rigid bodies within the skeleton.
Parameters#
In addition to the parameters available for the rigid bodies, the following parameters can be adjusted to configure the Ragdoll body:
Frame-Based |
Toggles frame-based animation on and off. When disabled, bone transformations are conditioned by physics, instead of being based on skinned animation data. This option is available for both the whole ragdoll body and individually selected bound bones. |
---|---|
Rigidity |
Allows to additionally constrain the motion of the skeleton. This parameter determines how uniform the motion of Ragdoll parts is. To achieve that, both linear and angular velocities of each separate rigid body are corrected according to the total velocities interpolated from all the bodies.
|
Enabling Ragdoll Animation#
When the character, for example, hits some obstacle or is shot and dies, it is necessary to turn off bone-based animation playback and simulate the character realistically falling according to the physical laws. When the Frame-based option is disabled, Ragdoll body is no longer driven by the bone transformations. It collapses according to Rigid body dynamics (masses of all rigid bodies, that represent parts of the skeleton, velocity damping, etc.), joint constraints and Rigidity of motion.
Combined Animation and Inverse Kinematics#
The problem with pre-baked animation is that it does not offer proper environmental interaction. For example, when walking up or down the hill, character's feet do not land firmly on terrain. Or as it climbs the ladder, the hands have to tightly grab the rungs. This effect is achieved with combined animation: motion animation is played for the basic bones, while smaller bones (feet or hands, for example) are simulated physically.
Frame-based animation can be disabled for each of the rigid bodies that approximate bones. Instead of following specific bone transformation, rigid body sags loose under its own weight and connects to collider objects underneath it.
For instance, physically-driven motion of the leg requires disabling bone animation of the whole limb: thigh, calf, and foot. Inverse kinematics allows to properly position the chain of bones given the position of the lowest bone in the hierarchy, the foot. So when the character walks or runs, his foot collides with the ground, while the knee bends and straightens according to the joint constrain.
The information on this page is valid for UNIGINE 2.20 SDK.