Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TargetJoint2D

The joint attempts to move a Rigidbody2D to a specific target position.
Read time 7 minutesLast updated 4 days ago

Definition

  • Type: Class
  • Namespace: UnityEngine
  • Assembly: UnityEngine.Physics2DModule
  • Inherits from: Joint2D
public sealed class TargetJoint2D : Joint2D

Remarks

This joint is the only joint that doesn't connect two Rigidbody2D together. Instead, it only operates on the single body it is connected to.
When connected, it will attempt to move the body to a specified TargetJoint2D.target position. When setting a target you can also set the TargetJoint2D.anchor position which is a point relative to the Rigidbody2D where forces will be applied.
The joint moves the body using a configurable spring that has a force limit.
An example usage for this joint might be to enable Collider2D to be dragged, selecting an anchor point and moving the body to the position under the mouse.

Properties

Property

Description

anchorThe local-space anchor on the rigid-body the joint is attached to.
autoConfigureTargetShould the target be calculated automatically?
dampingRatioThe amount by which the target spring force is reduced in proportion to the movement speed.
frequencyThe frequency at which the target spring oscillates around the target position.
maxForceThe maximum force that can be generated when trying to maintain the target joint constraint.
targetThe world-space position that the joint will attempt to move the body to.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.