Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved How can Configurable Joint be set up

Discussion in 'Physics' started by GamerLordMat, May 22, 2023.

  1. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    185
    Hello all,

    Please answer this bc really anbody who ever will touch this very important feature will have the same problems as I have.

    I have to use configurable Joint for my character, not character joint.

    so after 5 hours of brain fart and years of using Unity without understanding this cruel feature, I still dont understand how I can make a hinge joint with Configurable Joint let alone a leg for a Rag Doll.

    What is axis (definiton is clear but what does it do), what is secondary axis define (what kind of plane of rotation??).

    What do those extremely unintuitive Hammer-like things when configuring the joint? It doesnt map to any logical behaviour

    Nothing makes sense, I have been trying to do it with try and error but my brain doesn't compute.

    Cheers
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Configurable joints aren't actually that complicated if you're used to 3D vector math, it's just that it takes a while to get used to thinking the way they expect you to.

    And after this somewhat patronizing intro, some actual help:

    Axis and Secondary axis are used together to express the local coordinate system of the joint. So if you think of the "Axis" as the X axis of the joint, "Secondary Axis" would be Y, and the vector orthogonal to both of them would be Z. Note that you don't need to explicitly set the third vector, it's automatically calculated as the cross product of Axis and Secondary Axis. So let's call the "Axis", "Secondary Axis" and the third, automatically computed "Orthogonal Axis" X, Y, and Z respectively. These 3 axis are centered at the "Anchor" position - which is also expressed in local space.

    The X/Y/Z Motion and Angular X/Y/Z motion fields refer to these axis. By default, the joint's local X, Y and Z axis coincide with the body's local X, Y and Z. But let's say you set Axis to (0,0,1) and Secondary Axis to (0,1,0): the third axis would be automatically set to (-1,0,0).

    Setting "Angular Z motion" to "Free" and everything else to "Locked" would allow the body to freely rotate around (-1,0,0): that's the joint's Z axis, which also happens to be the body's local X axis (because the joint's Z is (-1,0,0), remember?).

    If you set Axis to (1,0,0) and Secondary Axis to (0,1,0), the third axis would be (0,0,1): these are the defaults. With these axis, setting "Y Motion" to "Free" and everything else to "Locked" would allow the body to slide along its local (0,1,0) axis, etc.

    It's just a matter of setting your axis so that the joint's local space suits your needs and using the right combination of Locked, Limited and Free linear/angular motion.

    Not sure what you mean, could you be referring to the angular limits?
     
    Last edited: May 23, 2023
  3. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    185
    thanks for the help, it was alos a big "you should have known this" moment when I realized that the "axis" is the x component. But let me tell you that is no comprehensive guid on this. E.g. Multiple Medium guides could not explain what Axis is.

    No worries regarding vector math, I have a Bachelor's Degree in Games IT ;D.
    Thank you very much for your reply, I actually solved it.

    Things that hindered my undertanding:
    1. Nowhere mentioned is that axis and secondary axis are related to the gameobject's LOCAL space (the gameobject of the Config Joint ) (at least this kind of thinking worked out for me, no where mentioned in the Documentation I think). it could have been also global space or the object's space the Joint is attached too, not my fault Unity not mentioning it
    So if my object is weirdly rotated, or totally off like mine (Blender export gone wrong), you have to know to which the axis relates/maps

    2. Unity uses Left-Handed coords for Cross-Product, I had recently some openGL (right-handed) programming so I was off their too

    3. (then more easy to understand) The plain of rotation is nowhere well explained, the plane's Normal is the Cross Vector/ Z (I mean could be also arbitrary defined)

    4. last thing that still bugges me is that the initial offset of the rotation of the object changes the angular limits (aka the Hammer things do not work correctly xD)

    With Kind regards
     
    Last edited: May 23, 2023
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    To be fair the docs do mention it, albeit in a very casual way:
    https://docs.unity3d.com/Manual/class-ConfigurableJoint.html
    Being a bit more explicit would be good, specifying that it's the local space of the GameObject that the Joint component is placed on, not the local space of the body it's attached to.

    Been bit by this one more times that I'm willing to admit :), as I also come from an OpenGL background.

    Hope you'll find joints a bit less confusing now, good luck!
     
    GamerLordMat likes this.
  5. JB-AI

    JB-AI

    Joined:
    Jan 9, 2023
    Posts:
    14
    I find the Articulation Body components more manageable than the Config Joint component.
     
    codebiscuits likes this.
  6. USIRG

    USIRG

    Joined:
    May 13, 2018
    Posts:
    10
    @arkano22 thanks for confirming my hypothesis :) I just discovered the exact meaning of axis when struggling with unexpected behavior after setting it to something other than the default.

    The explanations for axis and secondary axis in the Configurable Joints docs are vague and insufficient. I just submitted a comment on that docs page, referencing this discussion and pointing out that adding "axis defines the x axis of the joint's coordinate system in the game object's local space" etc. would already make things much better.