HingeJoint.limits Manual     Reference     Scripting  
Scripting > Runtime Classes > HingeJoint
HingeJoint.limits

var limits : JointLimits

Description

The limits of the hinge joint.

The joint will be limited so that the angle is always between limits.min and limits.max. The joint angle is in degrees relative to the rest angle. The rest angle between the bodies is always zero at the beginning of the simulation.

JavaScripts
// Make hinge limit for a door.

hingeJoint.limits.min = 0;
hingeJoint.limits.minBounce = 0;
hingeJoint.limits.max = 90;
hingeJoint.limits.maxBounce = 0;

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Awake() {
hingeJoint.limits.min = 0;
hingeJoint.limits.minBounce = 0;
hingeJoint.limits.max = 90;
hingeJoint.limits.maxBounce = 0;
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Awake():
hingeJoint.limits.min = 0
hingeJoint.limits.minBounce = 0
hingeJoint.limits.max = 90
hingeJoint.limits.maxBounce = 0

Modifying the limit automatically enables it.