- Home /
Hinge Joint not working in Unity 5
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;
function Update()
{
//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.
I've tried changing a bunch of values and seem to get some results, but there are definitely some changes somewhere that I don't understand. I think I'm just going to revert to version 4.5 unless I can find some kind of explanation of what changed with the hinge joints.
Having a very similar issue :/ Will let you know if I can figure anything let, also will keep an eye on this.
Hi,
Same problem here - fundamentally the script changes are not being applied. I've tried in normal code sections and in FixedUpdate. Looks to be a bug?
Answer by aurelioprovedo · Mar 06, 2015 at 11:50 AM
I've also encountered problems with physics joints when upgrading to Unity 5. I believe that in the new PhysX version, joints are much more picky. Try doing these two things:
If the rigidbodies have position or rotation constraints on any axis, make sure that only the connected bodies (the dominating ones) have those constraints. If both rigidbodies have the constraints, the joint f*cks up for some reason.
Try disabling the Enable preprocessing checkbox, at the bottom of the joint component in the Inspector panel.
Good luck!
"If child rigidbodies have the constraints, the joint f*cks up for some reason."
Thank you, mate. You've just fixed my 2d ragdoll
Related to the constraints problem, I have a ConfigurableJoint and my prefab would get a bad collision and fly off when instantiated if the X Y and Z motions were set to Locked. I turned this to free, instantiated the prefab, then changed this to Locked and it worked.
Answer by HakJak · Jun 08, 2015 at 07:50 AM
Not sure if it helps you, but one thing I've noticed is that joints now behave differently if you don't have colliders also attached to the game objects.
Your answer
Follow this Question
Related Questions
Unity 5.6 upgrade pains 0 Answers
Asset Bundle Dependencies, Unity 5 0 Answers
Trying to visually show the growth stages of a seed 0 Answers
Unity 5.3.3f1: How to set an object as AssetBundle by script? 0 Answers
How to create a secure package? 1 Answer