Description
The spring attempts to reach a target angle by adding spring and damping forces.
The spring.spring force attempts to reach the target angle. A larger value makes the spring reach the target position faster.
The spring.damper force dampens the angular velocity. A larger value makes the spring reach the goal slower.
The spring reaches for the spring.targetPosition angle in degrees relative to the rest angle. The rest angle between the bodies is always zero at the beginning of the simulation.
hingeJoint.spring.spring = 10;
hingeJoint.spring.damper = 3;
hingeJoint.spring.targetPosition = 70;
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
void Awake() {
hingeJoint.spring.spring = 10;
hingeJoint.spring.damper = 3;
hingeJoint.spring.targetPosition = 70;
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
def
Awake():
hingeJoint.spring.spring = 10
hingeJoint.spring.damper = 3
hingeJoint.spring.targetPosition = 70
Modifying the spring automatically enables it.