- Home /
Hinge joint limits not working.
I'm working on a 2D project, and we're trying to make plants that react when the player walks past. I've used hinge joints at the base of each plant, but the limits I have set (10° and -10° respectively) are ignored and the plants just continue to rotate, until they are laying flat against the ground.
I'm using Spring: spring 10; dampener 0; target angle 0 and Limits: min -10; max 10; min bounce 0; max bounce 0
break and torque are infinite.
Any insights would be much appreciated!
Answer by SarfaraazAlladin · Dec 20, 2013 at 08:00 PM
I've Solved it! Though I'm not sure if this is a hack or the intended method.
-Two game objects per plant: The Plant, and a rigidbody
-Rigidbody is moved to the anchor point for the plant, and connected to hinge joint
-Make sure box collider has depth.
The box collider I had attached to my plants was set to 0 on z. Screwed the whole thing up! I set it to 0.1, and viola. Limits are working, but only while connected to the second game object.
Answer by supernat · Dec 20, 2013 at 06:45 AM
How are you rotating the plants? Are you letting the Physics engine control the rotation somehow? If you manually adjust the rotation, the hinge joint won't work. However, if you're manually adjusting the rotation, why not just limit it right there. Sorry to answer this, comments are broken right now in Unity Answers.
(Comments still not working) Thanks for your help! The Rotation is purely physics based. The only components on the plants are rigidbody,hinge joint, and box collider. One thing I hadn't considered when I posted this question: The plants are not kinematic, of course, but the player's rigidbody is kinematic. Would that effect the behaviour of the hinge joint?
Unless it is a bug in Unity, I would not think the kinematic state of the player would matter for this particular issue. Now if you told me the plants weren't bending at all, then yes it could be due to the player's kinematic state.
Did you set useLimits to true?
Looks like comments are available again at least!
Use limits is set to true. I'm trying to set up a configurable joint now to see if I can work around it, but I just don't get why the limits are being ignored. Originally I didn't have any other bodies connected, but I've since made empty game objects with rigidbodies, and connected each plant to one. The plants still bend past their limits, but are more restricted now. Still not perfect, but I'm getting somewhere.
Your answer
Follow this Question
Related Questions
Hinge Joint Limits in C sharp 1 Answer
Spring Joint Worm set-up 0 Answers
Weird behaviour with hinge joint 0 Answers
Hinge or Configurable Joint to rigidbody's certain coordinates 1 Answer
Joints 2D, rope 0 Answers