The type of joint.
Get PhysicsJoint.jointType to determine which joint type a PhysicsJoint handle represents, for example when you iterate over the joints connected to a body.
Create the corresponding definition, for example PhysicsDistanceJointDefinition for DistanceJoint, and pass it into PhysicsWorld.CreateJoint to create a joint of that type.
// Check the type of an existing joint before deciding how to handle it. using UnityEngine; using Unity.U2D.Physics;
public class CheckJointTypeExample : MonoBehaviour { void Start() { PhysicsWorld world = PhysicsWorld.defaultWorld; PhysicsJoint myJoint = world.CreateJoint(new PhysicsDistanceJointDefinition { bodyA = world.CreateBody(), bodyB = world.CreateBody(), distance = 2f });
if (myJoint.jointType == PhysicsJoint.JointType.DistanceJoint) { Debug.Log("This is a distance joint."); } } }
| Property | Description |
|---|---|
| DistanceJoint | Constrain the distance between a pair of bodies. |
| IgnoreJoint | Used to ignore collision between two specific bodies. As a side effect of being a joint, it also keeps the two bodies in the same simulation island. |
| RelativeJoint | Constrain the relative translation and rotation between a pair of bodies. This joint type is also know as a Motor joint. |
| SliderJoint | Constrain the relative translation along an axis between a pair of bodies. This joint type is also know as a Prismatic joint. |
| HingeJoint | Constrain the rotation between a pair of bodies. This joint type is also know as a Revolute joint. |
| FixedJoint | Constrain a fixed translation and rotation between a pair of bodies. This joint type is also know as a Weld joint. |
| WheelJoint | Constrain a translation and rotation between a pair of bodies. |