Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

DOTS tools to handle Animator

Discussion in 'Data Oriented Technology Stack' started by alexandre-fiset, Oct 11, 2019 at 7:14 PM.

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    379
    I have made some DOTS helpers to play around with Animator component.

    It can be found here on GitHub https://github.com/Parabole/AnimatorSystems and its purpose is to allow jobbed systems to interact with the Animator component.

    Think of it as a middle man that receives instructions and then apply it to the Animator. It also mirror some information such as the current AnimatorStateInfo in IComponentData.

    I'm sharing it because I think there are not enough examples of hybrid usage in the forums and it may help people learning to use Dynamic Buffer and things like that.

    Here is an example job that sets four parameters on all animators.

    Code (CSharp):
    1.     private struct TestJob : IJobForEach_BBBB<BoolParameter, TriggerParameter, FloatParameter, IntParameter>
    2.     {
    3.         public int BoolHash;
    4.         public int TriggerHash;
    5.         public int FloatHash;
    6.         public int IntHash;
    7.        
    8.         public void Execute(DynamicBuffer<BoolParameter> setBool,
    9.             DynamicBuffer<TriggerParameter> setTrigger,
    10.             DynamicBuffer<FloatParameter> setFloat,
    11.             DynamicBuffer<IntParameter> setInteger)
    12.         {
    13.            
    14.             BufferUtils.AddBool(BoolHash, true, setBool);
    15.             BufferUtils.AddFloat(FloatHash, 99, setFloat);
    16.             BufferUtils.AddInteger(IntHash, 77, setInteger);
    17.             BufferUtils.AddTrigger(TriggerHash, setTrigger);
    18.         }
    19.     }
    Note that some of these things might not be super efficient and that I do not intend to officially support the package / fix reported bugs. We use this internally for our game development and just thought it would be nice to share it with the community.

    The package will also become irrelevant as soon as Unity deploys its DOTS Animatoré
     
    createtheimaginable likes this.
  2. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    81
    Nice work. We actually did something very similar in my project.

    Depending on what features ship with the DOTS animation package this will probably be useful for some time still. :)