Physics Joints

A PhysX joint is a component that links PhysX actors to constrain their movement. There are multiple types of joints that each constrain the actors in different ways.

Joints can be used for simple things like door hinges, up to complex configurations like rag dolls.

Joining Actors

Joints can be used to link:

There are two ways that a joint component can link actors.

Using Object References

You can use the object references on the joint component to specify both the parent actor and the child actor:

Linking Actors

With this method, the game objects for the actors and the joint don’t need to have a specific hierarchy, they can be placed just next to each other. This also allows to create loops of linked actors. On the other hand, you always need to know exactly which actors shall be linked.

Note:

The Child Actor of a joint always has to be specified this way.

Using the Object Hierarchy

To determine which Parent Actor to link the joint to, you can utilize the object hierarchy. If no parent actor is specified as an object reference, the joint will automatically traverse its object hierarchy upwards and search for the closest object with a static or dynamic actor. If it finds one, the joint will link to that object as the parent actor.

If it does not find any such actor on a parent node, the joint will attach to ‘the world’, meaning it will be fixed to its current world position.

This method can be useful especially when you want to put the joint into a prefab. For example, if you have a prefab for a chandelier that can swing around, you can set up the joint to only reference the actor that represents the chandelier, but the prefab does not contain an actor for the anchor point. If this prefab is placed into a scene, the rule that a joint without a parent actor just gets linked to the world, means that you can easily place these prefabs in a scene, and they will swing around the location where they have been instantiated.

However, if your scene contains for example a moveable room, you can also place it there and make sure to attach the chandelier prefab as a child node of the moveable room actor. That means, the joint of the chandelier will now link the chandelier actor with the moveable room actor, and thus whenever the room moves, the chandelier will be physically dragged along as well.

Important:

This method of linking actors only works properly, if the parent actor is either static or kinematic. It doesn’t work for simulated dynamic actors, as the transform update introduces jitter.

Joint Position

The position and rotation of a joint object specifies the pivot point. For revolute joints, spherical joints and 6DOF joints the position of the joint determines around which point the linked actors rotate. For fixed joints the position still affects how strong forces may become due to lever effects.

For distance joints the joint position determines from where the distance is computed. Only for prismatic joints is the position of the joint less relevant, though for computational stability, it should still be somewhere in between the linked actors.

Video: Basic Setup

video

Using the ChildActorAnchor Property

Using the ChildActorAnchor property is entirely optional and often not needed. Basically this option is used to reference any object, and tell the joint that the position and orientation of that object should be the anchor point where the joint acts upon the child actor. For most joint types this is rarely needed. If you link two actors with a revolute joint, the position of the joint already defines where between the actors the hinge will be.

However, this setup always assumes that the two actors should start out in the ‘default configuration’ of the joint. For example, for a revolute joint with a stiff spring, the default configuration is when it is fully relaxed, meaning you could not put them into a start configuration where the joint is already under tension.

Similarly, for a distance joint, the child actor would always need to start out such that the joint position is exactly at the position of the actor, where it should link to the actor. This can be problematic especially when the distance joint uses a minimum distance, as the joint would immediately push away the actor, potentially with high speed.

Using a dedicated object to specify the anchor point, both situations can be fixed. The anchor point specifies the position at which the joint affects the child actor. For most joint types the rotation of the anchor point is important as well. If the anchor’s transform is identical to the joint’s transform, it is redundant and could be left out. However, if it is different from the joint’s transform, this difference basically tells the joint how much its start state deviates from the ‘default configuration’. For example for a revolute joint the position of the anchor should always be identical to the joint’s position, otherwise the child actor will jerk towards the revolute joint at startup. However, the rotation may deviate from the joint’s rotation, which specifies how much the joint is already rotated at startup.

Video: How to use the Anchor Property

video

Shared Joint Component Properties

These properties are shared among all joint types:

Joint Types

These types of constraints are currently available:

Joint Stability

Joining multiple actors in a chain can quickly result in really bad simulation results. Have a look at dynamic actor simulation stability for ways to improve this. When working with joints the following aspects help a lot:

Also have a look at NVIDIA’s recommendations: Configuring Joints for Best Behavior (nvidia.com)

See Also