• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dot · Nov 01, 2010 at 07:37 PM · hingejointconfigurablejoint

hingeJoint.angle equivalent for ConfigurableJoint?

I believe title is self explanatory.

how would ConfigurableJoint's equivalent for HingeJoint.angle look like?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by UnitedBluff · Jul 13, 2015 at 10:02 AM

I came up with this and it seems to work. For some reason, in Jareikos function, secondary and third axes were switched, so my simple solution was simply to switch them again. On a sidenote: why are these functions not build in ? How can anyone make gameplay without reading values ? Anyway here is the function. The values returned in the Vector3 are between -180 and 180.

 public float to180(float v) {
         if (v > 180) {
             v = v - 360;
         }
         return v;
     }
     Vector3 jointRotation(ConfigurableJoint joint)
     {
         Quaternion jointBasis = Quaternion.LookRotation(joint.secondaryAxis, Vector3.Cross(joint.axis, joint.secondaryAxis));
         Quaternion jointBasisInverse = Quaternion.Inverse(jointBasis);
         var rotation =  (jointBasisInverse * Quaternion.Inverse(joint.connectedBody.rotation) * joint.GetComponent<Rigidbody>().transform.rotation * jointBasis).eulerAngles;
         return new Vector3(to180(rotation.x), to180(rotation.z),to180(rotation.y));
 }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Miestry · Aug 19, 2021 at 06:53 AM 0
Share

Thanks a lot!

avatar image
0

Answer by Jean-Fabre · Nov 18, 2010 at 12:00 PM

Hi,

Assuming you want to rotate around x axis:

-- select the connected rigid body

-- lock every axes BUT angular X motion ( Angular XMotion should be set to #free, the rest to #lock)

-- set the angular Xdrive mode to "velocity"

-- set the angular Xdrive position spring to 0 ( we don't need this for velocity drive)

-- set the angular Xdrive position damper to 10 ( varies depending on weight and volumes of RB)

-- set the angular Xdrive position force to 20 ( varies depending on weight and volumes of RB)

Generally I set the damper value to half of the the position force. that might be wrong, but that works so far.

then as the thing is playing, change the target velocity X value to 1, or 2, maybe more, the joint will turn, set back to 0 to stop rotating the joint.

A very important settings when you want to do accurate joints.

-- modify the anchor value to define where the pivot point reference is ( leave as is for no

for a complete rig using just configurable joint set up as hinges:

http://forum.unity3d.com/threads/66871-Excavator-simulation

Hope it helps,

Jean

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0
Wiki

Answer by jareiko · Jul 17, 2013 at 10:30 PM

This isn't quite right yet but I think I have the beginnings of a solution:

 Quaternion jointRotation(ConfigurableJoint joint) {
     Quaternion jointBasis = Quaternion.LookRotation(joint.secondaryAxis, Vector3.Cross(joint.axis, joint.secondaryAxis));
     Quaternion jointBasisInverse = Quaternion.Inverse(jointBasis);
     return jointBasisInverse * Quaternion.Inverse(joint.connectedBody.rotation) * joint.rigidbody.rotation * jointBasis;
 }

You can then use the .eulerAngles property to get the angles. The X component corresponds to the primary joint axis. Hopefully, Y and Z will correspond to secondaryAxis and the implicit third axis, but I haven't checked that these are correct yet. If they're not correct, the jointBasis calculation may need to be tweaked.

Eg:

 float angle = jointRotation(joint).eulerAngles.x;
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by inum76 · Oct 07, 2015 at 01:16 AM

I found while using scrips, C#, The Rigidbody falls asleep. You need to wake it up within the script during each update. This is my vid on the subject if you wish to check it out. Link: ConfigurableJointScript 1 Hope this helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How do I set up a ConfigurableJoint so that it behaves just like a HingeJoint? 1 Answer

Help with Hinge and steering wheels 0 Answers

When add joints to wheelcollider then it is not collide with other collider 0 Answers

Sloppy HingeJoints 0 Answers

Hinge Joint with no displacement, strict rotation limits 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges