| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsDistanceJoint The created joint.
Create a PhysicsDistanceJoint in the world. See PhysicsDistanceJoint.Create.
Use this method to connect two bodies with a distance constraint, keeping them a set distance apart, similarly to a spring or a rope.
// Connect two existing bodies with a distance joint. using UnityEngine; using Unity.U2D.Physics;
public class CreateDistanceJointExample : MonoBehaviour { void Start() { PhysicsWorld world = PhysicsWorld.defaultWorld; PhysicsBody body1 = world.CreateBody(); PhysicsBody body2 = world.CreateBody();
PhysicsDistanceJointDefinition jointDefinition = new PhysicsDistanceJointDefinition { bodyA = body1, bodyB = body2, autoDistance = false, distance = 2f }; PhysicsJoint distanceJoint = world.CreateJoint(jointDefinition); } }
| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsRelativeJoint The created joint.
Create a PhysicsRelativeJoint in the world. See PhysicsRelativeJoint.Create.
| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsIgnoreJoint The created joint.
Create an PhysicsIgnoreJoint in the world. See PhysicsIgnoreJoint.Create.
| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsSliderJoint The created joint.
Create a PhysicsSliderJoint in the world. See PhysicsSliderJoint.Create.
| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsHingeJoint The created joint.
Create a PhysicsHingeJoint in the world. See PhysicsHingeJoint.Create.
| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsFixedJoint The created joint.
Create a PhysicsFixedJoint in the world. See PhysicsFixedJoint.Create.
| Parameter | Description |
|---|---|
| definition | The joint definition to use. |
PhysicsWheelJoint The created joint.
Create a PhysicsWheelJoint in the world. See PhysicsWheelJoint.Create.