Constraining Physics Objects

As the name suggests, a MassFX constraint (or "joint") restricts the movement of rigid bodies in the simulation. Some examples of constraints in the real world include hinges, nails, zip lines, and axles.

All constraint presets create the same type of helper object with the same settings. The different constraint types, such as Hinge and Ball & Socket, simply set some useful default values for the resulting constraint.

A constraint helper object can either link two rigid bodies together or anchor a single rigid body to a fixed position in global space. The constraint constitutes a hierarchical relationship: The child object must be a dynamic rigid body, while the parent object can be dynamic, kinematic, or nothing (to anchor to global space).

By default, a constraint is "unbreakable": No matter how strong the forces you apply to it or how far you cause it to violate its limits, it will remain in effect and try to move its rigid bodies back into the desired range. However, you can set a constraint to be breakable with independent force and torque limits beyond which the constraint turns off and no longer applies to the simulation.

Parent and Child Objects

Most constraints connect two rigid bodies. The constraint is linked to the parent rigid body, moving and rotating along with it. For example, a car and its door are connected by a hinge constraint, with the car as the parent and the door as the child. The limits of how far the door can open and close do not change as the door rotates, but instead are relative to the car's orientation.

A constraint between two dynamic rigid bodies behaves similar to the real world: Forces applied to one rigid body can carry over to the other, in either direction. Most of the time, driving a car pulls the car door along with it. However, if some hefty (and possibly inebriated) fraternity brothers run out of gas and push their car by its open doors, the car body also moves, assuming the doors don't break. If the parent object is dynamic, it is just as likely to move as the child.

Creating a Constraint

To create a constraint between two objects, select the parent object in the scene, followed by the child object, then choose one of the Constraint presets from the flyout on the MassFX Toolbar. The constraint is automatically placed at the pivot point of the parent object. Then, as you move the mouse in a viewport, the system tracks the mouse cursor to set the display size of the constraint. The closer you move your mouse to the parent object, the smaller the constraint becomes. To finalize the constraint display size and finish creating the constraint, click the mouse.

TipIf either or both objects are not rigid bodies, MassFX asks if you want to apply the Rigid Body modifier before placing the constraint.

You can change the display size later as a property of the constraint. It affects only how large the constraint draws in views, and has no effect on the simulation effects of the constraint.

The placement of the constraint affects the offset from the parent where the constraint is applied. In cases where two rigid bodies abut, such as a door connected to a door frame, you usually place the constraint at the pivot of the child object. But in cases where two rigid bodies are separate, such as a ball swinging from a hook, the ideal position for the constraint is often at the pivot of the parent object. The Advanced rollout of the MassFX Constraint helper has buttons to move the constraint automatically to either of these locations for you.

Creating a World Constraint

You can also constrain a rigid body relative to a location in the scene. This is accomplished by setting the Parent of an existing constraint to nothing, or "undefined," by clicking the X button next to the Parent button in the Connection rollout of the MassFX Constraint helper. Alternatively, simply assign a constraint to a single selected rigid body; this automatically sets the body as the child and anchors the constraint in space.

Springs and Springy Constraints

The MassFX Constraint helper supports three types of springiness:

• Bounce: When a limited constraint reaches the edge of its limit, it can optionally bounce off the limit. For example, if you slam a door in your house, normally the latch clicks and it does not bounce back. To simulate this, you'd set the Bounce value of the constraint to 0.0. However, if you removed the latch, slamming the door would cause it to bounce back open off the door frame. For that, you'd use a non-zero Bounce value.
• Spring: When a limited constraint reaches the edge of its limit, it can optionally exceed the limit with a force applied to bring it back to the limit. For example, if you connected a bungie cord to yourself and a bridge and then jumped off the bridge, you'd fall freely until the length of bungie cord reached its resting length, as a result of reaching the Limit Radius value of the Translation aspect of the constraint. At this point the bungie cord would start to stretch, after which it would apply force to restore itself to its unstretched length. This latter force could cause you to accelerate and launch higher than necessary (the cord starts to bend on itself), but no force is applied once you're back inside the limit.
• The Damping attribute goes along with the Spring value to describe how much "mud" the object moves through once it exceeds the limit.
• Springiness:The Springiness values, found on the Spring rollout of the helper, represent what you might traditionally think of as a spring. Spring To Resting Position pushes the the parent and child objects back to their relative translation offsets on the first frame, while Spring To Resting Swing and Spring To Resting Twist affect their rotations. Larger values for Springiness apply more force.

Improving Preview Performance

Constraints have custom visualizations in viewports to show the locked/limited/free status of the translation, swing, and twist, along with a representation of those limits. This visualization is helpful for understanding the rotation and limits of a constraint. However, drawing these visualizations affects viewport performance.

If you are previewing a simulation that has many constraints, you might wish to disable the display of helpers to improve the speed of viewport udpates. You can do so on the Display panel by turning on Hide By Category Helpers.