Lumberyard
Legacy Reference

Collision Detection and Response

Collision detection and response involves the realistic depiction of attachments that collide with the body of a living character that simulate real-world physics. To do this, a collision proxy is used to approximate parts of a character body such as the legs and torso with a simple geometry shape. Using a collision proxy is more efficient than undertaking all the necessary computation required for collision detection and response with a polygonal mesh.

For information about how to set up a collision proxy attachment, see Proxy (Collision) Attachments.

Collision Detection

Collision detection involves checking to see if a blue proxy capsule/sphere overlaps (collides) with a gray proxy lozenge. For pendulums, a blue proxy is always connected to an attachment socket (pivot) at one end.

Collision Response

Collision response is handled by projections. If a dynamic (blue) proxy capsule/sphere collides with an auxiliary (gray) proxy lozenge, the blue proxy is projected or moved away until it no longer overlaps (collides with) the gray proxy lozenge. This means projecting (moving) the blue proxy capsule/sphere perpendicularly from the lozenge surface or rotating it out of the lozenge.

Lumberyard performs two consecutive constraint checks for collision detection. First, the blue proxy capsule/sphere is moved out of the gray proxy lozenge, and second the spring particle or pendulum rod movement is clamped to the shape of the bounding volume: spring ellipsoid, pendulum cone or half-cone, pendulum hinge, or translation projection.

After these two checks, the blue proxy capsule/sphere should be outside of the gray proxy lozenge but inside of the bounding volume. However, if the bounding volume is too small, the collision response may happen successfully only to have the bounding volume push the capsule/sphere back inside the lozenge.

There are four different projection methods used to move proxies to a non-colliding state, depending on the bounding volume, in addition to No Projection:

If No Projection is selected, collisions are ignored and no response is initiated.

Spring Ellipsoid Response

Selecting Shortvec Translation moves a gray proxy sphere away from a blue proxy lozenge using the shortest distance possible. For springs, only gray proxy spheres (and not capsules) are supported with spring motions.

Pendulum Cone and Half-Cone Response

Selecting Shortarc Rotation rotates a gray proxy capsule out of a blue proxy lozenge using the smallest angle possible.

Pendulum Hinge Response

Selecting Shortarc Rotation rotates a gray proxy capsule out of a blue proxy lozenge using the shortest direction possible. For hinges, there are only two ways for a capsule to rotate out of a lozenge.

Selecting Directed Rotation rotates a gray proxy capsule out of a blue proxy lozenge along the (green) direction of the hinge-plane.

Translational Projection Response

In the case of rotations (Shortarc Rotation and Directed Rotation), the pivot for a blue proxy capsule must lie outside of a gray proxy lozenge. The pivot is the spherical portion of the capsule that is connected to the attachment socket.

If the capsule pivot lies inside of a lozenge, collisions cannot be resolved and the proxies remain in an overlapping (collided) state. This can occur for secondary animations on characters where the simulation update is triggered after the animation update and it happens that the animation itself moves proxies into each other or creates invalid proxy configurations that break the simulation. To handle these cases, Translational Projection type is used, which defines the direction of movement. There are two types of translational projections:

  • Shortvec Translation

  • Directed Translation

Note

It is important that the new socket is on the same joint where you want to perform the translation and appears in the list of attachments ahead of the pendulum attachment that you want to move out. You can change the order of attachments in Geppetto. This order defines the order of execution, so the translation operation moves the joint out of the proxies before the pendulum attachment is executed.

Selecting Shortvec Translation moves a blue proxy capsule out of a gray proxy lozenge along the shortest vector from the surface of a sphere enclosing the joint, where the radius of the sphere is specified. This type should be used in cases where there are only a few lozenges, due to potential unpredictable and undesirable movements.

If an overlap is detected, the sphere is translated out of the lozenge along the shortest vector to the surface. This method of translation is only recommended for setups with just a few lozenges where the results are predictable. Otherwise, issues may arise where the first shortvec translation moves a capsule out of the first lozenge and directly into a second lozenge. These issues are very likely with complex setups where many lozenges are close together or overlap. It can also happen that it projects out in the wrong direction and produces undesired "tunneling" effects.

Choosing Directed Translation moves a blue proxy capsule out of a gray proxy lozenge along either a Translation Axis (defined relative to a joint and socket orientation) in its negative direction, or moves it out relative to a selected Directional Translation Joint, which defines the translation axis between the joint and socket. Optionally, you can select a joint, which forms a translation axis between the location of the joint and the socket.

Both options allow you to specify a capsule in the direction of the translation axis; however, the capsule is always projected out in the predefined direction even if the capsule is behind the lozenge, which makes "tunneling" unlikely.