{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Method CreatePositionMotor | Unity Physics | 1.1.0-pre.3
docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method CreatePositionMotor

    CreatePositionMotor(BodyFrame, BodyFrame, float, float)

    Create a PositionMotor joint. This is a motorized prismatic joint that drives bodies toward the specified relative target position, along one axis.

    Declaration
    public static PhysicsJoint CreatePositionMotor(BodyFrame bodyAFromJoint, BodyFrame bodyBFromJoint, float target, float maxImpulseOfMotor = Infinity)
    Parameters
    Type Name Description
    BodyFrame bodyAFromJoint

    Specifies the anchor point and axis of translation of bodyA. This is the body that has the motor. The BodyFrame parameters should be set as follows: The Position should be set to the anchor position. The Anchor Position is an offset from the center of the body with the motor (bodyA), and represents the anchor point of translation. The Axis is the normalized direction of the motor rotated relative to the orientation of bodyA. Value must be normalized. The Perpendicular Axis must be perpendicular to Axis. Value must be normalized.

    BodyFrame bodyBFromJoint

    Specifies the pivot point and axis of alignment in the space of bodyB. This is the Connected Body. If no body is connected, then bodyB is the World and data should be in world-space. It is recommended to 'Auto Set Connected' this body to bodyA such that they share a pivot point (code is not supported for this not to be enabled) and should be calculated using the following transformation: RigidTransform bFromA = math.mul(math.inverse(worldFromB), worldFromA). The BodyFrame parameters should be set as follows: The Position should be calculated as math.transform(bFromA, AnchorPosition); where AnchorPosition is the translation in bodyAFromJoint. This is the position of the Anchor relative to the Connected Body. The Axis should be calculated as math.mul(bFromA.rot, axis), where axis is the Axis of bodyAFromJoint. This is the translation of the Axis relative to the Connected Body. Value must be normalized. The Perpendicular Axis should be calculated as perpendicular to Axis (for bodyB). Value must be normalized.

    float target

    The target distance between the bodies' anchor points, along the Joint's Axis. This is the position the motor will be driving towards.

    float maxImpulseOfMotor

    The magnitude of the max impulse that a motor constraint can exert in a single step. This is a motor specific usage that does not represent the impulse threshold to break the motor.

    Returns
    Type Description
    PhysicsJoint

    A Constraint.

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)