- Home /
How do I set up a ConfigurableJoint so that it behaves just like a HingeJoint?
I'd like to set up a ConfigurableJoint that behaves exactly like a HingeJoint. I want to do this so I can lock the joint at certain times. I saw a similar question and the answer makes sense for basic setup, but I'm not getting the same behavior as my HingeJoint.
I think my Angular XDrive parameters don't match what Unity uses for its HingeJoint. Does any one know what settings Unity uses? I'm using velocity mode because the motor of a HingeJoint only takes a target velocity. I haven't assigned a value to Position Spring or Position Damper.
Thanks!
Answer by taters · May 25, 2011 at 02:23 PM
Hi,
to mimick a hinge joint, you would need to set the config joint as:
XMotion, YMotion, ZMotion all on 'Locked'
angularXMotion, angularYMotion, angularZMotion all set to 'Free'
set angularXDrive mode to 'position'
set angularXDrive spring to '20' or whatever.
set angularYZDrive mode to 'position'
set angularYZDrive spring to '20' or whatever.
then set the 'Target Rotation' to be what you want. If you want an 'angle', like 90 deg, then you can use:
somejoint.targetRotation = Quaternion.Euler(new Vector3(0,90,0));
All this is relative remember, so if you have the object in the position you want already, then leave rotation to 0 then it should just act like a springy thing in all axis (from the pivot point of course)
The above is more like a springy ball socket joint actually. If you want a true hinge, just 'Lock' the appropriate angular?Motion things you want frozen (e.g a hinge on X you would lock Y and Z angular motion). or just leave 0 in the vectors when setting the Target Rotation.
You could then 'lock the joint at certain times' by setting the target position (make sure the spring is set high enough). Add damping on it too to stop it going bananas when it goes to its target if the spring is high.
This way, all physics will behave happily.
This is presuming you are adding the components through the editor, not with scripting. (...or are you wanting to do it all through script?)
Hope it helps / hope its correct - sorry if it's not - going from memory. :)
Dave
Your answer
Follow this Question
Related Questions
When add joints to wheelcollider then it is not collide with other collider 0 Answers
Sloppy HingeJoints 0 Answers
hingeJoint.angle equivalent for ConfigurableJoint? 4 Answers
hing joint issue,Hing Joint Issue in tow truck 0 Answers
Joint: Swing & Twist? 1 Answer