Version: 5.3 (switch to 5.4b)
ЯзыкEnglish
  • C#
  • JS

Язык программирования

Выберите подходящий для вас язык программирования. Все примеры кода будут представлены на выбранном языке.

HingeJoint.spring

Предложить изменения

Успех!

Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.

Закрыть

Ошибка внесения изменений

По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста <a>попробуйте снова</a> через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.

Закрыть

Отменить

Руководство
public var spring: JointSpring;
public JointSpring spring;

Описание

The spring attempts to reach a target angle by adding spring and damping forces.

The JointSpring.spring force attempts to reach the target angle. A larger value makes the spring reach the target position faster.

The JointSpring.damper force dampens the angular velocity. A larger value makes the spring reach the goal slower.

The spring reaches for the JointSpring.targetPosition angle in degrees relative to the rest angle. The rest angle between the bodies is always zero at the beginning of the simulation.

See Also: useSpring, JointSpring.


        
using UnityEngine;
using System.Collections;

public class HingeExample : MonoBehaviour { void Start() { HingeJoint hinge = GetComponent<HingeJoint>(); // Make the spring reach shoot for a 70 degree angle. // This could be used to fire off a catapult. JointSpring hingeSpring = hinge.spring; hingeSpring.spring = 10; hingeSpring.damper = 3; hingeSpring.targetPosition = 70; hinge.spring = hingeSpring; hinge.useSpring = true; }

}

Modifying the spring does not automatically enable it.

Enabling the motor overrides the spring, given the spring was enabled. If the motor is again disabled the spring will be restored.