- Home /
Doors and Hinge Joints
Please see the GIF image. Why does this HingeJoint behaves like this? It has a -90,90 limit. And uses Spring.
I want it to stop and the -90,90 angles even if I push it.
Any idea what could be the cause?
Image of Joint Settings: https://i.imgur.com/9Vln5kU.jpg
Don't use Spring, as the name said it is for spring effect.
It's for a spring effect within the hinge joint. It's not supposed to act like a spring joint.
I want it to spring back. Removing the spring yields the same problem.
How are you moving your character? If you're using transform.translate or rigidbody.moveposition ins$$anonymous$$d of rigidbody.addforce it's probably the cause. If you're "forcing" the character to move past the gate's spring limit something has to give, either you pass through the gate or the hinge breaks. Unity favors hinge breaking in this case.
Answer by Qvothe · Oct 18, 2016 at 10:19 PM
Without seeing your code, I'm going to assume it has something to do with your door/gate's parent object. As your gate is a child of the pillar, then your bounds are going to be relative to the pillar (the parent object), and not worldspace.
On the second picture, under "Motor" you've checked "use limits" but right above that you do not have "Use Motor" checked. I don't know how the code is written, but I would assume that the limits on the motor don't apply unless you're actually using the motor.
Also, I know it should be obvious, but check to make sure that you're putting your bounds on the correct axis, and set them to 89.5 degrees instead of true 90. A player won't notice the difference and it'll stop any clipping issues you might run into as well. I mention this because your joint settings in the editor do not specify which axis is being "locked".
You should also check your "lock" on the translation, as that could be another possible source of problems.
If it were me, what I would do is remove the collider from the door itself. I would put a proximity collider around the door with a listener. When your player's collider enters the door collider, I would have it trigger a "door opens" animation.
The child/parent setup seems to be set up correctly from what I can see.
Limits and $$anonymous$$otor are different things, you can use limits without the motor.
The rigidbody constraints are clear in the image?
Who says he's using a translation?
An alternative method isn't really an answer to a specific question.
Sorry if I'm co$$anonymous$$g across a bit harsh, but that answer is full of misinformation and speculation.
No code involved in the problem I mentioned. All relevant information is supplied in the image and the GIF.
The limits are not limited to $$anonymous$$otor. The limits actually work if I use AddForce on the door. But when I use a character with a collider, this is what I get.
I double checked the axis. It is correct.
Doing an animation is one solution, but not the ones I want atm sadly :(