Struct PhysicsJoint
A set of constraints on the relative motion of a PhysicsConstrainedBodyPair. Most joint types can be described with a single instance, but complex setups like ragdoll joints require more than one instance to stabilize. In these cases, you should associate multiple joints using PhysicsJointCompanion.
Namespace: Unity.Physics
Syntax
public struct PhysicsJoint : IComponentData
Properties
BodyAFromJoint
The anchor point and orientation in the space of the first body.
Declaration
public BodyFrame BodyAFromJoint { get; set; }
Property Value
Type | Description |
---|---|
BodyFrame |
BodyBFromJoint
The target point and orientation in the space of the second body.
Declaration
public BodyFrame BodyBFromJoint { get; set; }
Property Value
Type | Description |
---|---|
BodyFrame |
EnableCollision
Declaration
[Obsolete("EnableCollision has been removed from PhysicsJoint. Use a PhysicsConstrainedBodyPair on this entity instead. (RemovedAfter 2020-08-15", true)]
public int EnableCollision { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
EntityA
Declaration
[Obsolete("EntityA has been removed from PhysicsJoint. Use a PhysicsConstrainedBodyPair on this entity instead. (RemovedAfter 2020-08-15", true)]
public Entity EntityA { get; set; }
Property Value
Type | Description |
---|---|
Entity |
EntityB
Declaration
[Obsolete("EntityB has been removed from PhysicsJoint. Use a PhysicsConstrainedBodyPair on this entity instead. (RemovedAfter 2020-08-15", true)]
public Entity EntityB { get; set; }
Property Value
Type | Description |
---|---|
Entity |
JointData
Declaration
[Obsolete("JointData has been deprecated. Use mutable interfaces instead. (RemovedAfter 2020-08-15", true)]
public BlobAssetReference<JointData> JointData { get; set; }
Property Value
Type | Description |
---|---|
BlobAssetReference<JointData> |
JointType
An optional property to provide a hint about what behavior the underlying constraints represent. Use it in conjunction with convenience setters in JointComponentExtensions to modify constraints. Its value is set when you use a factory method to construct a new PhysicsJoint instance, but it has no effect on joint behavior. See also CreateBallAndSocket(float3, float3), CreateFixed(BodyFrame, BodyFrame), CreateHinge(BodyFrame, BodyFrame), CreateLimitedDistance(float3, float3, Math.FloatRange), CreateLimitedHinge(BodyFrame, BodyFrame, Math.FloatRange), CreatePrismatic(BodyFrame, BodyFrame, Math.FloatRange), CreateRagdoll(BodyFrame, BodyFrame, Single, Math.FloatRange, Math.FloatRange, out PhysicsJoint, out PhysicsJoint).
Declaration
public JointType JointType { get; set; }
Property Value
Type | Description |
---|---|
JointType |
Version
A counter to keep track of changes to the joint's definition. Use it with back-ends like Havok that cache information about the joint if its properties have not changed.
Declaration
public byte Version { get; }
Property Value
Type | Description |
---|---|
Byte |
Methods
CreateBallAndSocket(float3, float3)
Create a BallAndSocket joint.
Declaration
public static PhysicsJoint CreateBallAndSocket(float3 anchorA, float3 anchorB)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.float3 | anchorA | Specifies the anchor point in the space of body A. |
Unity.Mathematics.float3 | anchorB | Specifies the target point in the space of body B. |
Returns
Type | Description |
---|---|
PhysicsJoint |
CreateFixed(BodyFrame, BodyFrame)
Create a Fixed joint.
Declaration
public static PhysicsJoint CreateFixed(BodyFrame bodyAFromJoint, BodyFrame bodyBFromJoint)
Parameters
Type | Name | Description |
---|---|---|
BodyFrame | bodyAFromJoint | Specifies a reference point and orientation in the space of body A. |
BodyFrame | bodyBFromJoint | Specifies a target point and orientation in the space of body B. |
Returns
Type | Description |
---|---|
PhysicsJoint |
CreateHinge(BodyFrame, BodyFrame)
Create a Hinge joint.
Declaration
public static PhysicsJoint CreateHinge(BodyFrame bodyAFromJoint, BodyFrame bodyBFromJoint)
Parameters
Type | Name | Description |
---|---|---|
BodyFrame | bodyAFromJoint | Specifies the anchor point and axis of rotation in the space of body A. |
BodyFrame | bodyBFromJoint | Specifies the target point and axis of alignment in the space of body B. |
Returns
Type | Description |
---|---|
PhysicsJoint |
CreateLimitedDistance(float3, float3, Math.FloatRange)
Create a LimitedDistance joint.
Declaration
public static PhysicsJoint CreateLimitedDistance(float3 anchorA, float3 anchorB, Math.FloatRange distanceRange)
Parameters
Type | Name | Description |
---|---|---|
Unity.Mathematics.float3 | anchorA | Specifies the anchor point in the space of body A. |
Unity.Mathematics.float3 | anchorB | Specifies the target point in the space of body B. |
Math.FloatRange | distanceRange | The minimum required distance and maximum possible distance between the two anchor points. |
Returns
Type | Description |
---|---|
PhysicsJoint |
CreateLimitedHinge(BodyFrame, BodyFrame, Math.FloatRange)
Create a LimitedHinge joint.
Declaration
public static PhysicsJoint CreateLimitedHinge(BodyFrame bodyAFromJoint, BodyFrame bodyBFromJoint, Math.FloatRange angularRange)
Parameters
Type | Name | Description |
---|---|---|
BodyFrame | bodyAFromJoint | Specifies the anchor point, axis of rotation, and rest orientation in the space of body A. |
BodyFrame | bodyBFromJoint | Specifies the target point, axis of alignment, and reference orientation in the space of body B. |
Math.FloatRange | angularRange | The minimum required and maximum possible angle of rotation about the aligned axes. |
Returns
Type | Description |
---|---|
PhysicsJoint |
CreatePrismatic(BodyFrame, BodyFrame, Math.FloatRange)
Create a Prismatic joint.
Declaration
public static PhysicsJoint CreatePrismatic(BodyFrame bodyAFromJoint, BodyFrame bodyBFromJoint, Math.FloatRange distanceOnAxis)
Parameters
Type | Name | Description |
---|---|---|
BodyFrame | bodyAFromJoint | Specifies the anchor point and axis of rotation in the space of body A. |
BodyFrame | bodyBFromJoint | Specifies the target point and axis of alignment in the space of body B. |
Math.FloatRange | distanceOnAxis | The minimum required and maximum possible distance between the two anchor points along their aligned axes. |
Returns
Type | Description |
---|---|
PhysicsJoint |
CreateRagdoll(BodyFrame, BodyFrame, Single, Math.FloatRange, Math.FloatRange, out PhysicsJoint, out PhysicsJoint)
Declaration
public static void CreateRagdoll(BodyFrame bodyAFromJoint, BodyFrame bodyBFromJoint, float maxConeAngle, Math.FloatRange angularPlaneRange, Math.FloatRange angularTwistRange, out PhysicsJoint primaryConeAndTwist, out PhysicsJoint perpendicularCone)
Parameters
Type | Name | Description |
---|---|---|
BodyFrame | bodyAFromJoint | |
BodyFrame | bodyBFromJoint | |
Single | maxConeAngle | |
Math.FloatRange | angularPlaneRange | |
Math.FloatRange | angularTwistRange | |
PhysicsJoint | primaryConeAndTwist | |
PhysicsJoint | perpendicularCone |
GetConstraints()
Get the sequence of Constraint atoms to apply between the two bodies.
Declaration
public FixedList128<Constraint> GetConstraints()
Returns
Type | Description |
---|---|
FixedList128<Constraint> |
SetConstraints(FixedList128<Constraint>)
Set the sequence of Constraint atoms to apply between the two bodies.
Declaration
public void SetConstraints(FixedList128<Constraint> constraints)
Parameters
Type | Name | Description |
---|---|---|
FixedList128<Constraint> | constraints | A sequence of Constraint atoms to apply in order. |