Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 Collrain · Aug 22, 2018 at 10:01 AM · positionaxisjointstarget

Hinge joint target angle and joint axis

Hello,

I've had a good look at the documentation for joints and also had a google search for information but I'm struggling to understand and hoped that someone smart could explain it to me in a simple manor.

If I have a leg, just 1 leg, which has a joint where the hip is that connects to the world. Then a knee joint that is connected to the hip and finally an ankle that is connected to the knee. The knee joint would just rotate on one axis and the knee contracts and extends, I can then set a target angle and use the motor to make the knee try to maintain a specific angle. So lets say I set the target to 45 degrees and thus the knee bends upwards to that position. But with regards to the hip, it can swing forward and back but also outwards to the side. I would now have to use 2 axis and I'm struggling to understand how the relationship between using 2 axis effect the target position of a hinge joint?


I'm just working on things for fun and learning at the moment and I wanted to make a leg or arm that I can pick what angle I want the different joints to be at and then the leg or arm would try to move to those positions via the motor, bit like a crane I guess.


If someone who understands joints can explain how the target position is effected by 2 axis that would be awesome.


Thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by JVene · Aug 22, 2018 at 11:32 AM

A HingeJoint won't do 2 axis by itself. You could consider the configurable joint, but if you're just experimenting that would be a steep hill to climb. Instead, you could put two HingeJoints at basically the same position, but have one be the child of the other. One would handle the lateral rotation while the other the forward rotation you're already using. Putting a joint on an otherwise empty GameObject would allow for this two stage construction.


You're going to encounter the next phase of study for this kind of thing which I'll summarize for you. At some point you're going to want to place the foot at a position. To do that you have control only of the angles of the joints. To calculate what is required involves trigonometry, performing what is basically inverse kinematics. Forward kinematics would be what you're doing now, from hip to knee to ankle. The reverse naturally begins at the foot, which is placed by a position, which then translates into angles for the ankle, knee and hip. Focus on the knee. For any given distance from hip to ankle there is only one angle the knee can adopt. To calculate that angle, use the law of cosines (google provides). You create an imaginary line from hip to ankle, which forms a non-right triangle where the knee is the angle opposite the imaginary line. The law of cosines gives this angle because you'll calculate the length of the imaginary line, and will already know the upper and lower legs which form the triangle. Just follow the formula on any readable reference on using the law of cosines. The next calculation is for the hip. Use the law of cosines to calculate the interior angle of the imaginary triangle already discussed at the hip. The angle of the upper leg is that angle plus the angle of the imaginary line relative to the "straight" angle of the body (usually the Y axis). You will encounter the fact that the angle orientation you use for the GameObjects may not be the same as that given by standard trigonometric angles. Standard math assumes that zero degrees is a point on the X axis, not a point on the Y axis (where zero is up, like a clock). Positive rotations are counter clockwise from math, but you may see GameObjects orient that in reverse. Also, note that most trig functions require radians while you and the Euler functions of the Quaternion use degrees, so use Mathf.Rad2Deg (or Mathf.Deg2Rad) to convert. When you have the angles of the hip and knee, the ankle will be at a given coordinate by this reverse calculation. You can then extend this notion to the angle of the foot as required. Although you could place the foot according to the "toes", you should, for simplicity, place the foot based on the ankle position (save that extra work for fingers of a hand on an arm).

Comment
Add comment · Show 2 · 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 Collrain · Aug 22, 2018 at 01:32 PM 0
Share

Thanks very much for you thorough answer. I might have to give the configurable joints a go as I would like to encompass everything into a single joint for each limb if possible. Oddly enough I've already been working on the "next phase" as you described. It's just the joints that have been giving me the most trouble as I haven't used them all that much so my knowledge is pretty thin. Thank you again for clarifying that I'll need to use a configurable joint to achieve the 2 axis rotations, this little project I'm doing is a slow burner and I'm in no rush so I'll try and read up on the configurable joints. Any particular repositories of information for configurable joints that you would recommend beyond the standard documentation?

avatar image JVene Collrain · Aug 22, 2018 at 06:42 PM 0
Share

The PhysX engine is under the hood, so you may benefit from documentation and commentary google might find on its use.

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

109 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get an Objects position per axis? 1 Answer

target.gameObject Position 1 Answer

JS Move object over time 1 Answer

transform.position.y and x or z + 1? 0 Answers

How to control an object with a mouse? 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