Mechanical Joints

→ Mechanical Joint API

Mechanical Joints can be used to limit the movements of Rigidbody in local space. It is primarily intended for kinematic Rigidbodies.

Setup

The Mechanical Joint component should be placed on a GameObject with a Rigidbody with the isKinematic propery enabled.

Kinematic Rigidbodies will not move in the scene under influence of physics, only when they are moved by scripting or grabbed by an humanoid.

The Mechanical Joint component can limit these movements.

All limitations work in local space and are relative to the local location of the object at compile time.

Parameters

Limit Position XLimits the local X-position to the given minimum and maximum bounds. When the bounds are both zero the local X position is locked.
Limit Position YLimits the local Y-position to the given minimum and maximum bounds. When the bounds are both zero the local Y position is locked.
Limit Position ZLimits the local Z-position to the given minimum and maximum bounds. When the bounds are both zero the local Z position is locked.
Limit AngleLimits the local relative to the local rotation at compile time. When the angle is zero the local rotation is locked. The axis is the axis around which the rotation is possible.

Scene

The Mechanical Joint limitations will be shown in the scene using lines capped with spheres in the colour of the axis.

An example of a cube with a limitation on the X axis of 0.2 units to both sides:

Events

The Mechanical Joint component has events for executing functions based on the limitations. These work just like any other event:

In the example above, a sound will play when the local X position of the Rigidbody will reach the minimum value. In this case -0.2. Multiple events can be attached to the limitation to provide many possibilities.

Examples

The following instructions use Mechanical Joints: