docs.unity3d.com
    Show / Hide Table of Contents

    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

    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). CreateLimitedDOF(RigidTransform, bool3, bool3).

    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 readonly 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
    float3 anchorA

    Specifies the anchor point in the space of body A.

    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
    float3 anchorA

    Specifies the anchor point in the space of body A.

    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

    CreateLimitedDOF(RigidTransform, bool3, bool3)

    Create a LimitedDegreeOfFreedom joint.

    Declaration
    public static PhysicsJoint CreateLimitedDOF(RigidTransform offset, bool3 linearLocks, bool3 angularLocks)
    Parameters
    Type Name Description
    RigidTransform offset

    Specifies a target point and orientation in the space of body B.

    bool3 linearLocks

    Specifies which linear axes are constrained.

    bool3 angularLocks

    Specifies which angular axes are constrained.

    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 FixedList128Bytes<Constraint> GetConstraints()
    Returns
    Type Description
    FixedList128Bytes<Constraint>

    SetConstraints(FixedList128Bytes<Constraint>)

    Set the sequence of Constraint atoms to apply between the two bodies.

    Declaration
    public void SetConstraints(FixedList128Bytes<Constraint> constraints)
    Parameters
    Type Name Description
    FixedList128Bytes<Constraint> constraints

    A sequence of Constraint atoms to apply in order.

    Extension Methods

    JointComponentExtensions.GetLimitedDistanceRange(in PhysicsJoint)
    JointComponentExtensions.SetLimitedDistanceRange(ref PhysicsJoint, Math.FloatRange)
    JointComponentExtensions.GetLimitedHingeRange(in PhysicsJoint)
    JointComponentExtensions.SetLimitedHingeRange(ref PhysicsJoint, Math.FloatRange)
    JointComponentExtensions.GetPrismaticRange(in PhysicsJoint)
    JointComponentExtensions.SetPrismaticRange(ref PhysicsJoint, Math.FloatRange)
    JointComponentExtensions.GetRagdollPrimaryConeAndTwistRange(in PhysicsJoint, out Single, out Math.FloatRange)
    JointComponentExtensions.SetRagdollPrimaryConeAndTwistRange(ref PhysicsJoint, Single, Math.FloatRange)
    JointComponentExtensions.GetRagdollPerpendicularConeRange(in PhysicsJoint)
    JointComponentExtensions.SetRagdollPerpendicularConeRange(ref PhysicsJoint, Math.FloatRange)
    JointComponentExtensions.GetLimitedDOFAxes(in PhysicsJoint, out bool3, out bool3)
    JointComponentExtensions.setLimitedDOFAxes(ref PhysicsJoint, bool3, bool3)
    In This Article
    • Properties
      • BodyAFromJoint
      • BodyBFromJoint
      • JointType
      • Version
    • Methods
      • CreateBallAndSocket(float3, float3)
      • CreateFixed(BodyFrame, BodyFrame)
      • CreateHinge(BodyFrame, BodyFrame)
      • CreateLimitedDistance(float3, float3, Math.FloatRange)
      • CreateLimitedDOF(RigidTransform, bool3, bool3)
      • CreateLimitedHinge(BodyFrame, BodyFrame, Math.FloatRange)
      • CreatePrismatic(BodyFrame, BodyFrame, Math.FloatRange)
      • CreateRagdoll(BodyFrame, BodyFrame, Single, Math.FloatRange, Math.FloatRange, out PhysicsJoint, out PhysicsJoint)
      • GetConstraints()
      • SetConstraints(FixedList128Bytes<Constraint>)
    • Extension Methods
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023