Search Unity

Question coding an fk handle effector

Discussion in 'Scripting' started by raptor2234, Sep 28, 2022.

  1. raptor2234

    raptor2234

    Joined:
    Feb 15, 2021
    Posts:
    1
    Hello, I am working on creating an end effector for my scene in Unity. I am trying to follow these steps:
    1. Compute a translation matrix for each bone.
    2. Compute a rotation matrix for each joint.
    3. Multiply the matrices to get the full transformation matrix.
    4. Then extract the position and orientation from this matrix.
    I want the effector to appear at the top of my structure.
    upload_2022-9-28_0-30-50.png
    My issue is finding the correct formula to get this to work. When I fix the translation matrix, it messes up my rotation matrix. Any info is helpful. Here is my code:
    upload_2022-9-28_0-30-3.png

    Here is my tree:
    upload_2022-9-28_0-31-53.png
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    I think your problem comes from reading from .localEuler coordinates and feeding them back in as the rotation in your TRS() calls. At least that's the first place I would crosscheck, perhaps with a super-simplified structure you can reason about fully.

    Here's why I suspect that:

    All about Euler angles and rotations, by StarManta:

    https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html