Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsSliderJoint

A joint that requires defining a line of motion defined by the local anchor A. Body B may slide along the axis defined by the local anchor A. Body B cannot rotate relative to body A. The joint translation is zero when the local anchor origins coincide in world space. The joint uses local anchors so that the initial configuration can violate the constraint slightly.
Read time 5 minutesLast updated 12 days ago

Definition

public readonly struct PhysicsSliderJoint : IEquatable<PhysicsSliderJoint>

Constructors

Constructor

Description

PhysicsSliderJoint(Unity.U2D.Physics.PhysicsHandle)Create a joint from a physics handle.
PhysicsSliderJoint(Unity.U2D.Physics.PhysicsJoint)Create a PhysicsSliderJoint from the specified base joint. The provided joint must be a joint type of PhysicsJoint.JointType.SliderJoint.

Properties

Property

Description

bodyAThe first body the joint constrains.
bodyBThe second body the joint constrains.
callbackTargetGet/Set the Object that event callbacks for this joint will be sent to. Care should be taken with any Object assigned as a callback target that isn't a Object as this assignment will not in itself keep the object alive and can be garbage collected. To avoid this, you should have at least a single reference to the object in your code. To remove the object assigned here, set the callback target to NULL.
collideConnectedWhether the shapes on the pair of bodies can come into contact.
currentAngularSeparationErrorGet the current angular separation error for this joint, in degrees. This does not consider admissible movement.
currentConstraintForceGet the current constraint force used by the joint, usually in newtons.
currentConstraintTorqueGet the current constraint torque used by the joint, usually in newton-meters.
currentLinearSeparationErrorGet the current linear separation error for this joint, usually in meters. This does not consider admissible movement.
currentMotorForceGet the current motor force, usually in newtons.
currentSpeedGet the current joint translation speed, usually in meters per second.
currentTranslationGet the current joint translation, usually in meters.
definitionGet or set the joint definition. Reading returns the joint's current configuration, including _bodyA and _bodyB. Writing applies every configurable property in place but does not change the connected bodies, which are fixed when the joint is created.
drawScaleControls the scaling of the joint drawing.
drawTargetControls which Unity editor views this joint is drawn into.
enableLimitEnable/Disable the joint translation limit.
enableMotorEnable/Disable the joint motor.
enableSpringEnable/Disable a spring along the slider joint axis.
forceThresholdThe force threshold beyond which a joint event will be produced.
isOwnedGet if the joint is owned. See PhysicsJoint.SetOwner.
isValidChecks if the joint is valid.
jointTypeGets the joint type. See PhysicsJoint.JointType.
localAnchorAThe local anchor frame constraint relative to bodyA's origin.
localAnchorBThe local anchor frame constraint relative to bodyB's origin.
lowerTranslationLimitGet the lower translation limit.
maxMotorForceThe maximum force the motor can apply, usually in newtons.
motorSpeedThe desired motor speed, usually in meters per second.
ownerThe owner object associated with this joint, or NULL if no owner has been specified. This is a convenience property that returns the same value as PhysicsSliderJoint.GetOwner.
ownerUserDataGet PhysicsUserData that can be used for any purpose, typically by the owner only.
physicsHandleGet the physics handle.
selectedDrawingControls whether this joint is drawn individually when the world is drawn.
springDampingThe spring damping, non-dimensional.
springFrequencyThe spring stiffness, in cycles per second.
springTargetTranslationThe spring target translation, usually in meters. The spring-damper will drive to this translation.
torqueThresholdThe torque threshold beyond which a joint event will be produced.
tuningDampingControls the joint stiffness damping, non-dimensional. Use 1 for critical damping.
tuningFrequencyControls the joint stiffness frequency, in cycles per second.
upperTranslationLimitGet the upper translation limit.
userDataGet/Set PhysicsUserData that can be used for any purpose. The physics system doesn't use this data, it is entirely for custom use.
worldGet the world the body is attached to.
worldDrawingControls whether this joint is automatically drawn when the world is drawn.

Methods

Method

Description

DestroyDestroy the joint. If the object is owned with PhysicsJoint.SetOwner then you must provide the owner key it returned. Failing to do so will return a warning and the joint will not be destroyed.
DrawDraw this joint's current state once, as custom drawing.
GetOwnerGet the owner object associated with this joint as specified using PhysicsJoint.SetOwner.
SetOwnerSet the (optional) owner object associated with this joint and return an owner key that must be specified when destroying the joint with PhysicsJoint.Destroy. The physics system provides access to all objects, including the ability to destroy them so this feature can be used to stop accidental destruction of objects that are owned by other objects. You can only set the owner once, multiple attempts will produce a warning. The lifetime of the specified owner object is not linked to this joint i.e. this joint will still be owned by the owner object, even if it is destroyed. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner.
SetOwnerUserDataSet PhysicsUserData that can be used for any purpose, typically by the owner only.
WakeBodiesWake the pair of bodies the joint is constraining.

Static Methods

Method

Description

CreateCreate a PhysicsSliderJoint in the specified world.
DestroyBatchDestroy a batch of joints. Owned joints will produce a warning and will not be destroyed (see PhysicsJoint.SetOwner). Any invalid joints will be ignored.

Operators

Operator

Description

PhysicsSliderJointCast to a PhysicsSliderJoint from the base PhysicsJoint. The provided joint must be a joint type of PhysicsJoint.JointType.SliderJoint.
PhysicsJointCast to the base PhysicsJoint.