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

Showcase Unity ECS Physics + DOTS Animation Concept

Discussion in 'DOTS Animation' started by NT_Ninetails, Apr 18, 2021.

  1. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    Managed to get a CompoundCollider to work with the animation system :D

     
  2. dom_oliverr

    dom_oliverr

    Joined:
    Mar 2, 2021
    Posts:
    1
    Hi, looks great. How did you achieve this?
     
  3. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    Unfortunately, this system is still under development. In fact the way it was done in this video was done incorrectly and I didn't notice until I rotated the Entity 180 degrees on the Y axis. I have just fixed this problem last night so I would like to make sure the system is full proof before making any type of tutorial.
     
    Ruchir likes this.
  4. james7132

    james7132

    Joined:
    Mar 6, 2015
    Posts:
    166
    Looking to make character hitboxes in a similar way. A tutorial for this would be great.
     
  5. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    From my own experience, its not ready for prime time. Its an extremely convoluted and messy setup, its far more involved than dealing with simple hierarchies and the Transform System(which seems to make peoples heads spin when they look at it). I spent a while and took me a longer than Id care to admit to remember what the hell I was doing.

    The core of it is the AnimatedLocalToRoot buffer, which contains the LocalToRoot for every bone in a skinned entity and the SkinnedMeshToRigIndexMapping buffer, which contains the bone to skin mapping. If you start modifying that ALTR buffer you can see how it interacts with how skinning is affected(make sure to do this inside LateAnimationSystemGroup and after ComputeRigMatrices).

    For authoring, you will need to duplicate your character, setup a ragdoll on it, then delete everything but the actual ragdoll gameobject hierarchy, and parent it to your character's gameobject root. Just converting an existing character as is which has a ragdoll setup wont work due to how physics requires a flat hierarchy. I'm not really sure if unity themselves are planning to utilize the compound collider setup as demonstrated by the op so my experience only is with the flattened setup.
    In the authoring, create two buffers of all the entities from both that ragdoll gameobjects and the bone gameobjects and keep a record of them to copy data from one to another, and vice versa for ragdoll/nonragdoll states.

    Annoyingly you also need to move the animation package to the local packages folder because they made the components/buffers that you need to read from internal.

    my results:



    There are other issues with the bounds being incorrect(second gif displays this), still unsure how this is meant to be addressed due to how the entity splits itself into multiple entities during conversion but doesn't give you any ways to actually access the results of this.

    Finally not even sure how performant this is, my system seems to choke at around 256 characters(all with rigidbody setups), I think most of the time is spent due to unity physics and joints. I would've expected better? Anyway only tested on a 8700k/1070. I would hope I'm wrong in my setup(as is often the case!) and that the official way is way more performant.

    I'm praying to god that the next release (that hopefully arrives soon) really addresses this, as it was teased quite a while ago, and now with dots progress slowing, I fear if the next one doesn't have it, we're looking at another year or longer before official workflows even exist due to quickly development has slowed.

    If you want code I have no problems posting it but its a mess, and most likely wont work without larger chunks of my project. Probably just easier to explore a workflow that works for you with this info(if its helpful at all).
     
    Last edited: May 28, 2021
  6. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    He's right. My solution works specifically with compound colliders (as I am working on something else atm). This will not be ideal for projects that require differnet colliders on the same entity since as stated "how physics requires a flat hierarchy" so my approach would only be useful if you entity doesn't require special things like joints and specific colliders on the same entity. I could "cheat" by utilizing that CalculateContactPosition function on an IColliderJob to give it more versatility but that's a problem for another day.
     
  7. hirox_k

    hirox_k

    Joined:
    Apr 1, 2020
    Posts:
    2
    Hi! Thanks for the info. I was fumbling around with the ragdoll scene in UnityPhysicsSamples.
    This is my first time experiencing ECS and DOTS and the way it create those entities (including Mass, Velocity, Damping, Constrain, Bone attachment, etc), it seems these "data" don't have any type of parent-child relationship... is that why you called it "flat hierarchy"?

    btw, from what I've heard, there is no Joint Motors right now but good news, Unity physics dev is working on it, but no release time frame yet...
    The other useful tool would be rigid bodies driving bones for skinned mesh, but there's no news yet.
     
    Last edited: Jul 21, 2021