This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

RagDoll Body

RagDoll body enables inverse kinematics and procedural animation of a death sequence for bone-animated characters. This type of body is actually a set of Rigid bodies representing each bone of a character linked together by joints. These joints restrict movement of the bones relative to each other, providing realistic look.

Notice
RagDoll body can be assigned only to Mesh Skinned objects.

RagDoll animation

RagDoll animation

See also#

Assigning a RagDoll Body#

To assign a RagDoll body to an object via UnigineEditor perform the following steps:

  1. Open the World Hierarchy window.
  2. Select a Mesh Skinned object to assign a RagDoll body to.
  3. Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> RagDoll.

    Adding a body

  4. Set the body name and refer to the next section to create a RagDoll.

Creating a Physical RagDoll#

There are two ways of creating a RagDoll:

After the body is assigned to the Mesh Skinned, the first step is to create a Rigid body that will represent each bone in physical simulation.

For now, all the bones are free, meaning there is no Rigid body associated with them. To automatically generate a RagDoll, i.e. rigid bodies and approximating shapes along with joints to connect them, Create button should be clicked.

Notice
For proper automatic RagDoll generation the mesh should be in the Reference Pose (T-pose for human-like characters). If animation has been already applied to the mesh, apply an animation with the static Reference Pose.

Automatic generation is performed on the basis of the following parameters:

Approximation Shape#

Bones can be approximated either with Convex hull or Capsule, if Capsule shape box is checked:

  • Capsule provides very fast physics simulation and continuous collision detection.
  • Convex hull provides more accurate approximation.

If any other shape is required, approximation is to be done manually.

Approximation with capsules and convex hulls

Approximation with capsules and convex hulls
Notice
Remember that physical shapes need not reproduce the mesh precisely. Rough approximation provides physical interaction that is realistic and convincing enough.

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, all the shapes masses are recomputed. And the opposite way, if shape mass is changed, the total mass is modified correspondingly.

Approximation Error#

If convex hulls are used to approximate bones, the result may contain too much detail for collision geometry. As a rule, it is unnecessary, because a highly detailed shape does not provide noticeable visual difference while significantly affecting performance. Approximation error makes it possible to control the number of vertices in the resulting convex hull:

  • The lower the value, the more accurate and close to the mesh approximated shape is.
  • The maximum value of 1 provides quite rough approximation that may not cover all the mesh volume.

If a character is approximated with capsules, low value of approximation error provides more precise shape orientation.

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:

  • By the minimum value of 0, all the bones without exception are represented in rigid bodies and hence shapes.
  • By the maximum value of 1, approximation shapes are big and follow only the major bones. Small bones are included in this volume, but their individual transformations are not considered in physical simulation.
Minimum volume threshold     Maximum volume threshold
Volume threshold defines whether all bones up to the smallest one should be simulated separately or merged into bigger shapes

 

Body Hierarchy for Bones#

After a RagDoll has been created, all the bones that are represented in rigid bodies and shapes and specify their movement are marked as bound in the hierarchy. All the small bones not participating in physical body movement, stay marked as free. If automatically generated shapes are too loose, they can be tuned manually till approximation is satisfying enough.

Hierarchy of bodies and shapes that approximate bones can be saved into a *.node file and loaded from it. The set hierarchy can as well be removed from the RagDoll body and created anew.

Hierarchy of rigid bodies that represent bones

Manual Creation of a RagDoll#

It is also possible to create a RagDoll manually. In this case arbitrary shapes can be used to approximate bones of a RagDoll body. To create a RagDoll manually follow these steps:

  1. Create a Node Dummy that will be a parent node for future RagDoll hierarchy.
  2. Add a Dummy Object and make it 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.
  3. Create all Rigid bodies and shapes for the RagDoll 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, it will cause an error.
  4. Export the parent node into the *.node file.
  5. Select the character and load this file for its RagDoll body.
  6. Add and set up joints that connect rigid bodies within the RagDoll.

Enabling RagDoll Animation#

When the character hits some obstacle or, for example, he 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 box is unchecked, 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 a RagDoll, velocity damping, etc.), joint constraints and Rigidity of motion.

Notice
Enabling RagDoll animation influences only those bones that were physically approximated. For example, small bones that were discarded due to volume threshold, will still move. To prevent this from happening, mesh animation should be stopped explicitly.

Rigidity of Movement#

The Rigidity parameter allows to additionally constrain the motion of a RagDoll. It 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.

  • By the minimum value of 0, all RagDoll parts represented in rigid bodies move independently and unrestricted (of course, except for joint constrains). This gives an impression of loose and floppy movement.
  • By the maximum value of 1, RagDoll parts move in a uniform and stiff manner, which may seem over-constrained.

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.

Inverse Kinematics

With inverse kinematics feet of the characters are tightly glued to the floor no matter how tilted the surface is
Last update: 2024-12-13
Build: ()