I just upgraded from Unity 4.5 to 5 and everything is looking good except the hinge joint in my scene is behaving differently than it used to. I was using it to simulate a spring board using a script. When the player clicked on a object and dragged it back, the script would interpolate that distance the player dragged and set the max angle of hinge joint to seem like it was being pulled down. Then when the player released, it would reset the max angle so that it would spring up.
However after upgrading, the hinge joint snaps all the way back as soon as I hit play and won’t move at all. I also notice a message in the Inspector that wasn’t there in the previous version. It says “Max Limit needs to be larger or equal to the Min Limit.” That makes sense since my Min is 45 and my Max is 0, but that is the value that made it work the way I needed it to previously so I’m confused why it won’t work now.
Here is the script I have attached to the hinge joint object:
private var minAngle : float;
private var maxAngle : float;
var tracker : Transform;
var launchPivot : Transform;
//Calculates the distance between both objects
var dist = Vector3.Distance(tracker.position, launchPivot.position);
//Interpolates angle of object dependant on distance of two objects
var angle : float = Mathf.Lerp(maxAngle, minAngle, dist/5);
//Changes angle of object by limiting hingeJoint max limit property
GetComponent.<HingeJoint>().limits.max = angle;
Any help is appreciated. Thanks.