Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Fun with Joints..

Discussion in 'Physics for ECS' started by MidnightCow, Apr 11, 2023.

  1. MidnightCow

    MidnightCow

    Joined:
    Jun 2, 2017
    Posts:
    30
    Okay i figured i should make a post for this as i'd love to finally try and solve it..

    [This was originally tagged Havok but it's not - it is Unity.Physics - fixed]

    So i have some active ragdolls, and i'm driving rotation with anim data inside an iSystem..

    My hacky workaround is using PhysicsVelocity.CalculateVelocityToTarget and setting velocity directly which works but the ragdolls obviously don't respond well to collisions ( i have to manually detect collisions and lerp the 'strength' of this velocity based on the ragdoll being hit by something )..

    So i'm trying again to drive joint constraints directly.. The setup i'm trying out is as follows, three simple angular constraints on the joint, one for each rot axis ( and another joint with fixed linear position to hold the joints together )..



    So i'm using the anim data ( which is actually the transform.localEulerAngles of the source anim rig ) to drive the Min/Max values directly..

    This seems to work as shown in the following clip but as seen rotations aren't following exactly ( lower leg and feet ) and i think this is probably something to do with the math behind quaternions/euler/rotation-order etc etc.. Maybe using three angular constraints like this isn't ever going to produce the correct rotations, i have no idea as i don't know how it works under the hood or the maths involved..

    https://i.gyazo.com/abdc86c7654bf8e87713fa2c190d3ab1.gif

    It's been suggested to me maybe i'll have to use 3 joints to achieve this with some kind of ball and socket setup in order to drive all three axis like this, but any help/advice would be appreciated as i really don't know what i should be trying, i've tried various configurations up until now.

    Cheers.
     
    Last edited: Apr 12, 2023
  2. MidnightCow

    MidnightCow

    Joined:
    Jun 2, 2017
    Posts:
    30
    For reference:

    My source animation is just getting stored to a blob like this:
    upload_2023-4-11_12-28-26.png

    And the values are being applied to the joint constraints like this:
    upload_2023-4-11_12-29-23.png