Physics Joint

This section describes the specifications for exporting Physics Joints in Unity to USD.

What is a Physics Joint?

Physics Joint.
Physics Joint provides the connection between the two shapes.
Physics Joint can make 1-to-1 connections as well as 1-to-n connections.
1-to-n connections of Physics Joint.
Physics Joints can be used to provide some physical constraints.

Types of physics joint supported for export

Physics Joint export from Unity to USD supports the following.

Unity

USD

Description

FixedJoint

FixedJoint

Fixed connection of two shapes

HingeJoint

RevoluteJoint

Rotate around 1 axis

SpringJoint

DistanceJoint

Spring movement

ConfigurableJoint

D6Joint

Free rotation used for character articulation.In addition, spring effects can be added for each XYZ axis.

CharacterJoint

D6Joint

Free rotation used for character articulation

FixedJoint

FixedJoint is a joint that connects two shapes in a fixed manner.
FixedJoint.

RevoluteJoint

RevoluteJoint is a joint that rotates around a single axis.
RevoluteJoint.

SphericalJoint

SphericalJoint is a joint that can freely rotate around a single point.
SphericalJoint.
It can also provide an angular limit around one axis.

D6Joint

Of the Physics Joint, this joint encompasses all functions.
In addition to free rotation, angular and movement restrictions can be applied.
D6Joint.

DistanceJoint

DistanceJoint can represent a spring by specifying a minimum and maximum distance.
DistanceJoint.

Specifying Physics Joint in Unity

There are several rules for specifying Physics Joints in Unity.

  • Shapes participating in Physics Joint should be assigned a Rigidbody.

Rigidbody is added by a component.

RigidBody parameters.

By setting IsKinematic to On, the shape can be made to follow the transform operation at runtime.

  • The Physics Joint connects two shapes.

Add Physics Joint as a component of the shape of the connection source and specify the connection destination in its parameters.

Connecting Joint from RigidBody. Parameters when connecting.

Limitations to align specifications with USD side

In USD, when Rigidbody is nested, the behavior is different from Unity.

Note

DO NOT structure the Rigidbody within the Rigidbody shape because this will not work in USD.

In the following example, rootShape and Cube both have Rigidbody.
Do not nest RigidBody.

Base parameters for Physics Joint

The Joint class in Unity and the Physics Joint class in USD have parameters that are shared by all joints.

Below are the component parameters related to Physics Joint in Unity.
Base parameters for Physics Joint.
This red-lined parameter is exported to USD as a base parameter for the Joint class.

Unity

USD

Description

Body0

The target GameObject is used as Body0 of the USD

connectedBody

Body1

The shape specified in connectedBody is used as Body1 in USD

enableCollision

CollisionEnabled

Enable Collision

anchor

LocalPosition0

Local center position corresponding to Body0

connectedAnchor

LocalPosition1

Local center position corresponding to Body1

LocalRotation0

Local rotation information corresponding to Body0

LocalRotation1

Local rotation information corresponding to Body1

Break Force

BreakForce

Joint break force

Break Torque

BreakTorque

Joint break torque

LocalRotation0 and LocalRotation1 are automatically calculated from the given GameObject’s transform rotation.

In USD, this would be passed to the following red line parameters.
Base parameters for Physics Joint.

LocalPosition0 / LocalPosition1

LocalPosition0 / LocalPosition1 specifies the center position in local coordinates of Body0 and Body1, respectively.

LocalRotation0 / LocalRotation1

The rotation values for LocalRotation0/LocalRotation1 are the accumulated rotations from the common parent of the shapes corresponding to Body0 and Body1.

Joint parameters in USD.
Consider the case where there are two shapes, rootCube and Cube.

If there is rootCube and Cube and the direct parents are the same, the rotation values of the rootCube’s local transform and the Cube’s local transform are adopted, respectively.

If the hierarchy of the two shapes is different, trace back to the common parent.
The accumulated rotations of the target shape from this parent are adopted as the local rotation.
However, rotation in the parent transform is not included in this case.

Parameters of each Physics Joint

Describe which parameters are passed when passing Physics Joint in Unity to USD.

FixedJoint

The center of the FixedJoint is adopted as the center position from the edge of the two shape bounding box (AABB).
FixedJoint center.

HingeJoint

Use the Axis of the HingeJoint as the axis of rotation.
If Use Limits is On, Limits-Min and Limits-Max are used as rotation limits.
HingeJoint parameters.

SpringJoint

The larger the value of Spring, the stronger the spring restraint.
Damper specifies the damping of the spring.
Specify the minimum (Min Distance) and maximum (Max Distance) initial distances between shapes.
SpringJoint parameters.

ConfigurableJoint

ConfigurableJoint allows the rotation angle to be limited in each of XYZ.
ConfigurableJoint parameters.
In addition, the Position Spring and Position Damper of the X Drive, Y Drive, and Z Drive provide a spring effect for each axis.
Position Spring and Position Damper.

CharacterJoint

CharacterJoint can provide angular limits of rotation for each of the XYZ axes.
Low Twist Limit - High Twist Limit is the minimum and maximum value of rotation of the X-axis center.
Swing 1 limit is the limiting angle for rotation of the Y-axis center.
Swing 2 limit is the limiting angle for rotation of the Z-axis center.
CharacterJoint parameters.

Example of using Physics Joint

Here is examples of how Physics Joint can be used.

Uses rotation by one axis

It gives a mechanism that can perform a single axis rotation for a gear floating in space.
PhysicsJoint sample.

Collider assignment

First, assign Collider to this shape.
This GameObject consists of assets made up of multiple meshes.
Collider is given as a cube or mesh convex.
Collider was given as a MeshCollider convex for each mesh.
Set convex in Mesh Collider.
All Collider gizmos displayed.
Displayed all colliders.

Rigidbody assignment

The Rigidbody was assigned to the GameObject “woodGear” of the Mesh’s parent.
Select the parent of the mesh and check the collider.
When played, the collision occurs as a single GameObject and the rigidbody free-falls according to gravity.
Play animation.

HingeJoint assignment

A HingeJoint is used to perform a single axis rotation on this gear.
A dummy cube was placed at the end of the axis and given a rigidbody.
Also, check the “Is Kinematic” checkbox in Rigidbody.
Set kinematic in Rigidbody.
Connect this Cube to the woodGear, which is the Rigidbody of the gear.
Add HingeJoint as a GameObject component of the Cube.
The parameter “Connected Body” of the HingeJoint is the GameObject of the gear “woodGear”.
Rigidbody is assigned to “woodGear”.
Also adjusted so that Axis is the same as the axial direction of the gear.
Assign HingeJoint.
As an external force to rotate this gear, we collided a sphere that was given a Rigidbody and a Collider.
Play animation using HingeJoint.
Please export this to USD and play in USD Composer in the same way to confirm that physics operations are performed.
Play animation in USD Composer.

Connect multiple Physics Joints

When connecting multiple Rigidbodies in succession, make sure that the Rigidbodies are not nested in the hierarchical structure of the scene.

In the following example, four GameObjects are placed flat.
Connect multiple Physics Joints in Unity.
The first “CubeBase” specifies IsKinematic in Rigidbody and is connected to “Cube1” by FixedJoint.
Specifying Kinematic to RigidBody, Specifying FixedJoint.
Rigidbody (IsKinematic is Off) and HingeJoint were added to “Cube1”.
Specify to disable Kinematic to RigidBody, Specifying HingeJoint.
  • Adjust the center position with Anchor and the direction of the axis of rotation with Axis.

  • Check the Use Limits checkbox and specify the Min and Max of the Limit.

Rigidbody and HingeJoint were specified for “Cube2” in the same way.
The following is displayed in Play.
Play animation.

Export the USD from Unity and verify that the same movement is made in Omniverse USD Composer.