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

Bug skinned animation works...but the positions of the bones are not updating?

Discussion in 'DOTS Animation' started by NT_Ninetails, Mar 17, 2021.

  1. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    I got my animation to work with mt model but when I tried to use the Socket Attach To Component presented in the samples, it parents correctly but doesn't move. I have tracked the issue down to the bones themselves not moving. idk if it's a glitch because there is some y movement (less than 0.01) but the animation moves way more than that. All i know since the bones aren't moving like the animation is so tthe socket attachment script doesn't work.

    Any Ideas?
    Here is the model import settings
    upload_2021-3-17_19-4-59.png
    imported component
    upload_2021-3-17_19-5-37.png

    Skimmed mesh part
    upload_2021-3-17_19-8-52.png

    bone thing
    upload_2021-3-17_19-9-12.png


    anything else i'm missing?
     
    Last edited: Mar 17, 2021
  2. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    quick update: i think i got it to work. I added a LateAnimationGraphWriteTransformHandle to a specific bone and now the bone updates properly. I don't know why but this works. My test was created inside the same project as the Unity Animations Demo projects so i don't know why my solution is different from the examples. In the demo examples they only needed to apply the LateAnimationGraphWriteTransformHandle to the root node specified in the skinned mesh but it looks like i have to add this to everything....

    i will label this as a bug unless someone has an answer.
     
  3. kite3h

    kite3h

    Joined:
    Aug 27, 2012
    Posts:
    197
    It hasn't been a few days since I started looking at DOTS Animation, so I don't know the exact details.

    I'll only tell you what I've found out now.

    SkinnedMeshRenderer is changed to MeshRender and deform is performed using the value of SkinMatrix buffer.

    Statemachine that acts as an Animator and Graph are created as blobs.

    Animation Graph creates RigDefinition based on bone information from RigComponent.

    GameObject Bones are changed to Entitiy Components after providing information to RigComponent.

    AnimationJob work is done only on Rig data.

    Rig Data is fed back to the Bone Entity Component.

    However, these Bone Entity Component Data have nothing to do with Skinning.

    Skinning only uses data from RigData.

    The reason for feeding back to Bone Component Data is for read buffer attachments or constraints.

    So no matter how much you move them, it's useless.

    If you want to edit the animation itself, you need to edit the Rig Data yourself. However, such a method is provided only as a contraint.
     

    Attached Files:

    rockin likes this.
  4. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    thanks for your help! i changed my code up a bit and now it's doing what i want :D. my goal was to have the ECS colliders move with the animation. This is for some simulation tests i wanted to experiment with but needed the colliders to move with the animation.

    upload_2021-3-18_13-26-50.png

    Code (CSharp):
    1.  
    2. public class BonePhysicsColliderUpdaterComponent : MonoBehaviour, IConvertGameObjectToEntity
    3. {
    4.     public GameObject RigGameObject; // gameobject with the rig component
    5.     public int index; // index of this object in the rig component
    6.     public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    7.     {
    8.         if (enabled)
    9.         {
    10.             dstManager.AddComponentData(entity, new PhysicsColliderFollowEntityData
    11.             {
    12.                 RigGameObject = conversionSystem.GetPrimaryEntity(RigGameObject),
    13.                 index = index
    14.             });
    15.         }
    16.     }
    17. }
    18.  
    19. //[UpdateAfter(typeof(MyFirstClip_PlayClipSystem))]
    20. public class Test01Thing : SystemBase
    21. {
    22.     EntityQuery q;
    23.     protected override void OnCreate()
    24.     {
    25.         q = GetEntityQuery(typeof(PhysicsCollider),
    26.             typeof(PhysicsMass),
    27.             ComponentType.ReadOnly(typeof(PhysicsColliderFollowEntityData)),
    28.             typeof(Translation));
    29.     }
    30.  
    31.     protected override void OnUpdate()
    32.     {
    33.         if (q.CalculateEntityCount() == 0) return;
    34.         Entities
    35.             .WithName("dddddddd")
    36.             .WithBurst()
    37.             .ForEach((Entity entity, ref Translation translation, ref Rotation rotation, in PhysicsColliderFollowEntityData data) =>
    38.             {
    39.                 var GetAnimatedLocalToWorld = GetBufferFromEntity<AnimatedLocalToWorld>();
    40.                 if (GetAnimatedLocalToWorld.HasComponent(data.RigGameObject))
    41.                 {
    42.                     var anims = GetAnimatedLocalToWorld[data.RigGameObject];
    43.                     LocalToWorld tmp = new LocalToWorld { Value = anims[data.index].Value };
    44.                     translation.Value = tmp.Position;
    45.                     rotation.Value = tmp.Rotation;
    46.                 }
    47.             }).Schedule();
    48.     }
    49.  
    50.     void log(string a)
    51.     {
    52.         UnityEngine.Debug.Log(a);
    53.     }
    54. }
    55.  
    56. public struct PhysicsColliderFollowEntityData : IComponentData
    57. {
    58.     public Entity RigGameObject;
    59.     public int index;
    60. }
     
  5. Sunstrace

    Sunstrace

    Joined:
    Dec 15, 2019
    Posts:
    40
    useful to deep understand the animation how works.