Version: 5.5
Slider Joint 2D
Target Joint 2D

Spring Joint 2D

Компонент Spring Joint 2D соединяет “пружиной” 2 управляемых Rigidbody физикой Sprite-объекта. Пружина будет применять силу вдоль этой оси между двумя объектами, пытаясь сохранить между ними заданное расстояние.

Свойство: Функция:
Enable Collision Могут ли 2 соединённых объекта сталкиваться друг с другом?
Connected Rigid Body Specify here the other object this joint connects to. Leave this as None and the other end of the joint will be fixed at a point in space defined by the Connected Anchor setting. Select the circle to the right of the field to view a list of objects to connect to.
Auto Configure Connected Anchor Check this box to automatically set the anchor location for the other object this joint connects to. (Check this instead of completing the Connected Anchor fields.)
Anchor The place (in terms of X, Y co-ordinates on the RigidBody) where the end point of the joint connects to this object.
Connected Anchor The place (in terms of X, Y co-ordinates on the RigidBody) where the end point of the joint connects to the other object.
Auto Configure Distance Check this box to automtically detect the distance between the two objects and set it as the distance that the joint keeps between the two objects.
Distance The distance that the spring should attempt to maintain between the two objects. (Can be set manually.)
Damping Ratio The degree to which you want to suppress spring oscillation: In the range 0 to 1, the higher the value, the less movement.
Frequency The frequency at which the spring oscillates while the objects are approaching the separation distance you want (measured in cycles per second): In the range 0 to 1,000,000 - the higher the value, the stiffer the spring.
Break Force Specify the force level needed to break and so delete the joint. Infinity means it is unbreakable.

Детали

(See also Joints 2D: Details and Hints for useful background information on all 2D joints.)

This joint behaves like a spring. Its aim is to keep a linear distance between two points. You set this via the Distance setting. Those two points can be two Rigidbody2D components or a Rigidbody2D component and a fixed position in the world. (Connect to a fixed position in the world by setting Connected Rigidbody to None). The joint aplies a linear force to both rigid bodies. It doesn’t apply torque (an angle force).

The joint uses a simulated spring. You can set the spring’s stiffness and movement:

A stiff, barely moving spring…

  • A high (1,000,000 is the highest) Frequency == a stiff spring.

  • A high (1 is the highest) Damping Ratio == a barely moving spring.

A loose, moving spring…

  • A low Frequency == a loose spring.

  • A low Damping Ratio == a moving spring.

When the spring applies its force between the objects, it tends to overshoot the distance you have set between them, and then rebound repeatedly, giving in a continuous oscillation. The Damping Ratio sets how quickly the objects stop moving. The Frequency sets how quickly the objects oscillate either side of the target distance.

This joint has one constraint:

  • Maintain a zero linear distance between two anchor points on two rigid body objects.

For Example:

You can use this joint to construct physical objects that need to react as if they are connected together using a spring or a connection which allows rotation. Such as:

  • A character who’s body is composed of multiple objects that act as if they are semi-rigid. Use the the Spring Joint to connect the character’s body parts together, allowing them to flex to and from each other. You can specify whether the body parts are held together loosely or tightly.

HINTS:

  • Zero in the Frequency is a special case: It gives the stiffest spring possible.
  • Spring Joint 2D uses a Box 2D spring-joint. Distance Joint 2D also uses the same Box 2D spring-joint but it sets the frequency to zero! Technically, a Spring Joint 2D with a frequency of zero and damping of 1 is identical to a Distance Joint 2D!
Slider Joint 2D
Target Joint 2D