Explore the properties you can use to let one 2D Physics Core object restrict a second so it can only slide along one axis, defined by the rotation of the first object.
Read time 3 minutesLast updated 13 days ago
Explore the properties you can use to let one 2D Physics Core object restrict a second object so it can only slide along one axis. For more information, refer to Add a constraint.
Note
This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.
Pose
Property
Description
Pose A Source
Sets how Unity finds the first object this constraint connects to. The options are:
Auto: Searches this GameObject and its parents for a Physics Pose component.
Custom: Uses the Physics Pose component you assign to Pose A Target.
Pose A Target
Sets the first Physics Pose component this constraint connects to. This property is available only if you set Pose A Source to Custom. Drag a GameObject with a Physics Pose component from the Hierarchy window to this property, or select the picker (⊙).
Pose B Target
Sets the second object this constraint connects. Drag a GameObject with a Physics Pose component from the Hierarchy window to this property, or select the picker (⊙).
Refresh Poses
Refreshes Pose A Target and Pose B Target and recreates the constraint.
Definition
Property
Description
Definition Asset
Sets an asset that sets the values of the properties in this section. By default, this property is empty, and Unity stores the values inside the component. To set a definition asset, drag a Physics Constraint Slider Definition asset from the Project window to this property, or select the picker (⊙). For more information, refer to Share properties across multiple 2D Physics Core components.
Collide Connected
Allows the shapes on the two connected objects to collide with each other and create collision or trigger events. By default, the constraint prevents this. For more information, refer to Collisions and interactions in 2D Physics Core.
Anchors
Set where each end of the constraint attaches. Local Anchor A attaches to the first object, and its rotation determines the axis the second object can slide along. Local Anchor B attaches to the second object. Each anchor has the following properties.
Property
Description
Auto
Calculates the anchor from the current placement of the two objects when Unity creates the constraint, so both anchors line up in world space. Enable this property to avoid the anchor snapping into place when you start the simulation. If you enable this property, Unity hides Position and Rotation, because it doesn't use the values you set.
Position
Sets the position of the anchor, relative to the position of the object it attaches to.
Rotation
Sets the rotation of the anchor in degrees.
Spring
Property
Description
Enable Spring
Connects the two objects with a spring, which stretches and compresses to try to bring the objects together. The strength of the pull is proportional to the current distance between the objects.
Spring Target Translation
Sets the target speed of the spring pulling and pushing.
Spring Frequency
Sets the stiffness of the spring in Hertz (cycles per second). A higher value makes the spring less stiff. The default is 0.
Spring Damping
Sets how quickly the spring stops pulling or pushing. A higher value makes the spring settle more quickly. The default is 0.
Motor
Property
Description
Enable Motor
Makes the constraint act as a winch to pull or push the two connected objects.
Motor Speed
Sets the target motor speed, in meters per second.
Max Motor Force
Sets the maximum force that the motor applies to reach the target speed, in newtons.
Limit
Property
Description
Enable Limit
Restricts the position of the second object.
Lower Translation Limit
Sets the minimum position for the second object in meters.
Upper Translation Limit
Sets the maximum position for the second object in meters.
Thresholds
Property
Description
Force Threshold
Sets the amount of linear force that creates an
OnJointThreshold2D
event.
Torque Threshold
Sets the amount of rotational force that creates an
OnJointThreshold2D
event.
Tuning
Property
Description
Tuning Frequency
Sets the overall stiffness of the constraint in Hertz (cycles per second). A higher value makes the constraint less stiff.
Tuning Damping
Sets how quickly overall the constraint stops pulling or pushing. A higher value makes the constraint settle more quickly.
Events: Calls a method or sets a parameter you select in the On Joint Threshold (JointThresholdEvent) section.
Callback Target
Sets the object that receives physics callbacks. This property is available only if you set Callback Source to Constraint or Joints.
Event settings
The properties in this section set the specific method this constraint calls or the parameter it sets, and control the behavior of the
On Joint Threshold (JointThresholdEvent)
method of the component. This section is available only if you set Callback Source to Events.
Property
Description
Activation
Sets when the constraint activates the callback method or sets the parameter. The options are:
Off: Doesn't activate the callback method or set the parameter.
Editor and Runtime: Activates the callback method or sets the parameter in the Unity Editor and at runtime.
Runtime Only: Activates the callback method or sets the parameter only at runtime.
Object
Sets the object with the method to call or parameter to update. Drag any object from the Hierarchy or Project windows to this property, or select the picker (⊙).
Functions
Sets the parameter to update or the method to call. Select a parameter or method from the Object, its components, or its script methods. You can set the parameter value to update to, or the method parameters to use.
Add (+)
Adds a new callback method to the list.
Remove (-)
Removes the selected callback method from the list.
User Data
Use the properties in this section to add your own data to the component, and read it using the