Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Get the external forces acting against a Joint of an ArticulationBody

Discussion in 'Physics' started by P4bloPilot, May 6, 2024.

  1. P4bloPilot

    P4bloPilot

    Joined:
    Aug 3, 2018
    Posts:
    1
    Hello everyone,

    In my scene I have an ArticulationBody setup in a hierarchy of three GameObjects, each one part of the ArticulationBody with its own Joint defined as a part of the ArticulationBody.

    It looks like this:
    - Articulationbody (Root body of the articulation)
    - Articulationbody (Joint type: Fixed)
    - Articulationbody (Joint type: Spherical)​


    I am applying different forces to the last Joint (Spherical joint with full freedom and no axis locked) and I would like to know the forces acting under this Spherical Joint.

    I understood from the documentation that this is possible thanks to the method ArticulationBody.GetJointExternalForces but I am struggling to get this information.

    I have identified the Index of my ArticulationBody through Articulationbody.Index and I think I have to use also:
    Code (CSharp):
    1. ArticulationBody.GetDofStartIndices
    , but honestly I think I am not understanding correctly the documentation.

    When I call:
    Code (CSharp):
    1. ArticulationReducedSpace space = myArticulationBody.jointForce;
    2. Debug.Log("Reduced Space 0: " + space[1]);
    3.  
    I can read always Zero for the 3 degrees of freedom of my spherical joint placed on the last element of the hierarchy.

    Could someone please give me a bit of clarity on how to achieve this or how to correctly use these methods?

    Many thanks and happy coding everyone
    Pablo