Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to convert between articulation body drive targets and transform rotation?

Discussion in 'Physics Previews' started by mbaske, Nov 4, 2021.

  1. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
    Hi, I'd like to retrieve articulation drive target values from their corresponding transforms' local rotations.
    Specifically, I have an animated character that I've rigged with spherical joints. While the animation is playing and the transform rotations update, I need to somehow read/calculate the sequence of associated X/Y/Z drive values that would need to be set for recreating the animated motion using physics. Is this possible? Thanks!
     
  2. Gustorvo

    Gustorvo

    Joined:
    Oct 26, 2017
    Posts:
    32
    you need to first convert the local rotation value of your animated character to angle-axis rotation, then take the inverse of your articulation body's anchorRotation multiplied by the axis and angle (from angle-axis function). This will give you vector3 where each axis corresponds to articulation drive/motor accordingly. Here is the my little extension method class for articulation bodies that I use to achieve exactly that.
     
    marshalljdem likes this.