Search Unity

Mesh Animator - Highly efficient animated crowds. For support, please use email.

Discussion in 'Assets and Asset Store' started by jschieck, Dec 7, 2014.

  1. RafaelGuimaraesBarbosa

    RafaelGuimaraesBarbosa

    Joined:
    Dec 14, 2019
    Posts:
    15
    Could anyone tell me if this work with toon shaders like flatkit asset? I tested another asset named GPU Instance but the mesh draw black, this asset work with another materials shaders???
     
  2. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    All of the other translation is sent to the baked model. Why is the rotation data corrupted? If I bake the rotation or translation into the animation then I have to have a separate process setting the Transform data at the end of the animation or wherever it is interrupted.

    I can't even get animations to play consistently. In shader mode the animations will sometimes start in the middle of the animation. In Snapshot the animations won't even start. I have to "play" and then "replay" to begin an animation.

    The checkbox to play on awake doesn't work in that it will always play no matter what it is set to.

    I used EVERY SINGLE SETTING on the animation AND the baking and none of them were acceptable. The only animation that seems to work is in place animations. For F***s sake the root motion settings don't even behave the same between Snapshot and Shader Mode.
     
  3. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    Just tried the update. No change in with the bugs I've listed.

    Shader Mode "Applied to Transform" root motion doesn't do anything.
    Shader Mode "Baked" root motion is completely incorrect. The movement is exaggerated.
    Shader Mode animations sometimes begin playing in the middle of the animation.

    Snapshot "Applied to Transform" only works properly when rotation is "baked into pose", otherwise it rotates out of control.
    Regarding this: If I were to bake the rotation into every animation I would need a transition animation to rotate to the proper direction after executing any animation. Meaning I would have to track my rotation, remember what direction the animation ends at, and then play a second to compensate for the baked rotation. This likely wouldn't work since the rotation doesn't work properly in the first place.

    I'm not even interested in Snapshot mode and it is the only mode that is even close to working.
     
  4. taavetmalkov

    taavetmalkov

    Joined:
    May 5, 2021
    Posts:
    8
    Does it run in AR android as with any other output?
     
  5. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    I've come to the conclusion that I can only do animations where the character is stationary and animations play in place.

    I'm going to try to continue with this asset as for all its faults it optimizes drawing so much I feel like I have to use it.
     
  6. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    The problem is probably related to the animation that happens when the game isn't playing, but here is the animation automatically playing when no default animation is selected, and when play on start is disabled.

    AnimationFinished is also not called.

     
  7. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    The only way I've found to work around the problem of Root translation/rotation is very long winded and tedious.
    I'm making my game on a flat plane and I'm sure this wouldn't work if you were translating in the Y plane...
    Also, the animation still plays automatically no matter what in Snapshot Mode.

    1) Most important: Nothing works properly unless you're using Snapshot mode.
    2) Your original animation MUST bake all transforms and rotations. Or just set a root motion node.
    3) In Mesh Animator: Root Motion Mode = Applied to Transform
    4) In Mesh Animator: Expose your "Root" in Expose Transforms. I'm just using hips.
    5) In your animation controller script, record your Y rotation and your translation in the XZ plane during OnAnimationFinished.
    6) In your baked animation create two events to set the rotation and position as follows.
    upload_2021-8-11_0-55-12.png

    And here is my proof of concept for the code in the animation controller and animation event system.


    Code (CSharp):
    1.  // called when an animation completes
    2.         meshAnimator.OnAnimationFinished += (anim) =>
    3.         {
    4.             Debug.Log("Animation finished");
    5.             AnimationEventReceiver.SetPosition();
    6.             AnimationEventReceiver.SetRotation(-90); //this will be per animation... so this will be a switch statement.
    7.             //transform.position = new Vector3(Root.transform.position.x, 0, Root.transform.position.z);
    8.         };
    Code (CSharp):
    1.     public void ApplyPosition() {
    2.         transform.parent.position = Position;
    3.     }
    4.     public void SetPosition() {
    5.         Position = new Vector3(Root.transform.position.x, 0, Root.transform.position.z);
    6.     }
    7.  
    8.     public void SetRotation(float rotation) {
    9.         Rotation += rotation;
    10.         if (rotation > 360) {
    11.             Rotation -= 360;
    12.         }
    13.  
    14.         if (Rotation < 0) {
    15.             Rotation += 360;
    16.         }
    17.     }
    18.  
    19.     public void ApplyRotation() {
    20.         transform.parent.rotation = Quaternion.AngleAxis(Rotation, Vector3.up);
    21.  
    22.         Debug.Log("Setting rotation " + Rotation);
    23.     }
     

    Attached Files:

    Last edited: Aug 11, 2021
  8. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    And this would work if the ANIMATIONS WOULD START PLAYING FROM THE BEGINNING.
    Seriously how the F*** does playing an animation with "Play" not work?
    It seems like 90% of the time the animation jumps straight to the end.
     
  9. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    Holy S***. You have to set the time every time you play an animation.


    Code (CSharp):
    1. if (Play && !meshAnimator.IsPlaying()) {
    2.             meshAnimator.SetTime(0);
    3.             Debug.Log("play");
    4.             meshAnimator.Play(SelectedAnimation.name);
    5.             Pause = false;
    6.             Play = false;
    7.         }
    Why?
     
  10. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    This is as good as I can do with this asset. You can see him slide a little when he gets out of the car, but the scale will be small and the door will be closed when it happens.

    Its caused by the fact that I'm using the hip location to translate the model.

     
    Last edited: Aug 12, 2021
  11. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    For anyone wanting to stop the animation from automatically playing.


    Code (CSharp):
    1.     void Start()
    2.     {
    3.         MeshAnimator.OnFrameUpdated += FirstAnimation;
    4.  
    5. ...
    6.  
    7.    void FirstAnimation() {
    8.         MeshAnimator.SetTime(0);
    9.         MeshAnimator.Pause();
    10.         MeshAnimator.OnFrameUpdated -= FirstAnimation;
    11.        
    12.     }
     
  12. LeekAndRibs

    LeekAndRibs

    Joined:
    Mar 7, 2017
    Posts:
    49
    Hi guys, I've been using the MeshAnimator for a long time now and I'm still very happy with it. However, I now have a problem that I haven't noticed before. I use pause / play to freeze certain units. This works pretty well on most androids, and anything newer or equals than iPhone X, too. On the iPhone 6s / 7, however, the entire mesh becomes invisible after calling Pause until I call Play again. I've already tried "@pragma target 3.0", but unfortunately that doesn't help. This happens with different meshes. Does anyone have a similar problem or any idea what might be the cause? Unfortunately, I have little to no idea about shaders :/

    I´m using the ShaderMeshAnimator and tried with Material Instancing On/Off.
     
  13. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    Use SetTime(time). I can only assume your animations are in place because moving animations don't work properly.
     
  14. LeekAndRibs

    LeekAndRibs

    Joined:
    Mar 7, 2017
    Posts:
    49
    Hi @darkwingfart Thank you for answering :) Pausing the animation works on newer devices without any problems. So instead I'm assuming an incompatible shader problem.
     
  15. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    Does anyone have any idea how to make rotations work?

    I've tried every combination of baking in the asset as well as the animation. The rotation ends up not affecting the parent object, or the object spins out of control.
     
  16. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    I decided to see if my animation controller would work on the dreaded Shader Animated Mode and got this.

    upload_2021-8-19_1-11-36.png

    Nothing is batched. Using the provided shaders.

    "Play When Offscreen" also doesnt work.
     
    Last edited: Aug 19, 2021
  17. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    The callback for OnFrameUpdated does not guarantee that the frame displayed is from the current animation.

    This code will often show the last frame of the previous animation.

    Code (CSharp):
    1.  
    2. void OnFrameUpdated() {
    3.         MeshRenderer.enabled = true;
    4.         Debug.Log("still subscribed");
    5.         MeshAnimator.OnFrameUpdated -= action;
    6.     }
    7. ...
    8. Action action = new Action(OnFrameUpdated);
    9. ...
    10. MeshRenderer.enabled = false;
    11.  
    12.             LastAnimationIndex = SelectedAnimation.Index;
    13.  
    14.             if (PlayNextAnimation) {
    15.                 //PlayNextAnimation = false;
    16.                 NextAnimation();
    17.             } else {
    18.                 SelectedAnimation = DefaultAnimation;
    19.                 PlayAnimation();
    20.             }
    21.             ApplyTransformFromLastAnimation();
    22.             UpdateBoundingSphere();
    23.             MeshAnimator.OnFrameUpdated += action;
     
  18. darkwingfart

    darkwingfart

    Joined:
    Oct 13, 2018
    Posts:
    78
    I got tired of this not working properly.
    Asked for and got a refund.
    Rolled my own system in less than a week that actually works and consists of two scripts and a shader.

    I USED NONE OF THE CODE FROM MESH ANIMATOR.
    Why would I?

    Give me another week and I'll have performance that is equal to the performance of this asset that took 7 years to be as bad as it is.

    99*99 animations.

    Performance in build.


    Performance in player showing batching, and since all the animations are stored in a Texture2DArray all animations will batch. Will work on all platforms that support texture arrays.

    upload_2021-8-26_17-10-34.png

    darkwingfart out
     
  19. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I have this working with the snapshot mode which is nice. However when I tried out the shader mode it runs badly, very badly in fact. This is using URP. I was mainly looking at the shader mode to try and reduce the batches which I see climb up to 1000 or more. Is shader mode working properly for others?
     
  20. gamezuv

    gamezuv

    Joined:
    Nov 6, 2013
    Posts:
    82
    Hi, can someone help integrating this asset with toony colors pro 2 shaders? Also, how do I get rid of mesh tearing at start of spawn?
     
    linq likes this.
  21. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I managed to get the shader mode version working properly now and running fast like it should have been, so I have now changed over to that for my app. Batches are now well under 100 all the time which is nice. It is not without some pain though... It seems that the rendering of the shader mode characters in the editor can totally stop working, i.e they are not visible. No error is displayed. The only way I have seen to get them working again in the editor is to restart Unity. They seem to be working fine on the devices tested though.
     
    Fibonaccov, Jmonroe and hopeful like this.
  22. LeekAndRibs

    LeekAndRibs

    Joined:
    Mar 7, 2017
    Posts:
    49
    Hi guys

    to come back to my post: I still can't solve the problem unfortunately. However, I also can't imagine that no one has noticed it yet. I create a new project, load the MeshAnimator, load some animated mesh from the asset store and create a ShaderMeshAnimator from it. When I then call "Pause()" on it, everything works as it should in the editor, the MeshAnimator stays exactly in the current frame and on play it resumes from there. Also on all Android smartphones tested by me everything is great. Likewise, everything works great on my iPhone XS. However, on my iPhone 6/6s/7 the "Pause()" function no longer works. When calling "Pause()" on these devices, the entire mesh becomes invisible. It seems like the shader is either deleting or discarding the current frame. However, as soon as I call "Play()" again, the animation resumes at the correct position and the mesh becomes visible again.

    Does anyone else maybe have the problem or didn't even notice it(that would be worse) while the game is already released?
     
    the_unity_saga likes this.
  23. LeekAndRibs

    LeekAndRibs

    Joined:
    Mar 7, 2017
    Posts:
    49
    I was able to solve it with this line in the shader(MeshAnimator.cging):
    Code (CSharp):
    1.     float currentFrame = clamp(lerp(min(floor(normalizedTime * animTimeInfo.y), animTimeInfo.y - 1), animTimeInfo.w, paused), 0, animTimeInfo.y - 1);)
    Somehow, on certain devices, either "min" or "floor" seems to give incorrect results. If I simply assign any number to "currentFrame", the respective frame is displayed and the mesh remains visible. So on old iPhones "currentFrame" seems to contain any frame outside the available frames of the respective animation. Unfortunately, I don't know anything about shaders and don't know any way to display the contents of "currentFrame" to specifically solve the bug.

    However, it works now and I can continue working on the game for now :)
     
  24. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    EDIT: This happens with the MeshAnimator/Standard shader. It doesn't happen with MeshAnimator/Unlit/Texture or MeshAnimator/Legacy/Diffuse. Those were the only two others I tried and they worked fine. My suspicion is that there's a bug in the modified Standard shader provided with the asset. If anyone has a fix that would be great.

    ORIGINAL POST BELOW
    -----------------------------------

    I'm seeing an issue where setting parameters on one GPUShaderAnimated object is affecting the animation state of all others using that material. My entire crowd always plays the same animation on the same frame. Changing values on one affects all others.

    Looking at the code, it does use MaterialPropertyBlock for the pertinent fields, so the data on the shader should be decoupled between GameObjects, but it isn't.

    Is this a bug or is this expected behavior?
     
    Last edited: Oct 13, 2021
    hopeful likes this.
  25. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Hey @jschieck - Thank you for making this asset. I bought it in 2017 and while it was solid for a while it is currently growing a bit unreliable. I totally understand your predicament in keeping it current though. I don't know how Asset Store authors do it with the way Unity is constantly rug pulling with breaking releases.

    Would you consider open sourcing Mesh Animator? Another classic one called Dynamic Decals recently went through a similar situation where the author found the cost/benefit of maintenance too much. The community offered to get it on Github and now people are maintaining it.

    https://github.com/EricFreeman/DynamicDecals


     
    noor_games_commercial likes this.
  26. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    Another option, which I advise for everyone writing code for the asset store, is to aim for compatibility with LTS releases.
     
  27. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    When you use a lodgroup to cull out a snapshot mesh far away, when the mesh is visible again it no longer moves.
    any workaround?
    upload_2021-10-17_17-59-12.png
     
  28. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    I tried Coco07 shader fix, still getting creatures turning invisible in URP.
    It's possible that urp 12 fixes those. I'm in 8.3.
    Back to snapshot.
     
  29. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Is this asset still supported? A lot of negative reviews recently and no fixes for a few months.
     
  30. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,684
    If you are wanting a reply from the developer - @jschieck - you should tag him or contact him directly.
     
  31. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    I did after, he still supports it :)
     
    hopeful likes this.
  32. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Support would have fixed shader and LOD desync, after a year both are still broken.
    So I think he meant that he "supports" people's decision to give him money :D
     
    Quast likes this.
  33. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    That is good to know, might go with GPU Instancer - Crowd Animations instead then since that one has been recommended to me.
     
  34. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Hey @jschieck any thoughts on the open source thing?

    Personally, without a way forward where there's a community supporting the codebase, I'll be moving off of Mesh Animator. It's just too finicky.
     
    laurentlavigne and Quast like this.
  35. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    another bug: when you're calling Play a lot then animation freezes up in snapshot mode (the only one that's reliable in URP).
     
    Klausology likes this.
  36. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    impressive, heres hoping you sell it on the asset store!

    I do enjoy assets such as these.
     
    jeromeWork likes this.
  37. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    thanks for thew update dev, urp support is always nice

    think ill test it out and make a project dedicated around pushing your asset and see whats new
     
  38. windlord048

    windlord048

    Joined:
    Oct 24, 2014
    Posts:
    1
    Hi @jschieck I'm using MA with Unity 2020.3.34 (HDRP). I've tried to create a Lit shader graph but looks like it doesn't work with Mesh Animator. I baked with Shader Animated mode with Shader Graph support enabled. Please help me to take a look at this.
    Screenshot 2022-10-20 082151.png
    Thank you
     
  39. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    URP shaders are broken....
     
    Klausology likes this.
  40. tanaka0123

    tanaka0123

    Joined:
    Nov 6, 2016
    Posts:
    11
    I too have a broken URP shader.
    Snapshot mode works a bit., but shader mode is no good.

    I am contacting Mr. jschieck with the following information.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    I tried to use Mesh Animator but it does not work.

    I followed the manual and made the following settings
    I have followed the manual and made the following settings, but when I place the generated "xx_AnimatedMesh" in the scene, it remains in T-pose.

    Please let me know the possible causes.

    unnamed.png
    unnamed (1).png
    (In snapshot mode, the image may appear to move a few frames.)

    System Requirements: Mesh Animator 2.0.0.
    Mesh Animator 2.0.26
    Unity 2021.3.14
    URP12.1.8

    Also, I've checked the sample scenes.
    Snapshot mode for the MAExample_Crowd scene is working, but the The hand mesh is wrong.
    Shader mode does not seem to be working.

    Snapshot mode
    unnamed (2).png

    Shader mode
    unnamed (3).png
     
    Last edited: Jan 12, 2023
    the_unity_saga likes this.
  41. hebesun

    hebesun

    Joined:
    Nov 30, 2017
    Posts:
    2
    what is issue with if I create a new animation, it going influence old animation's mesh. I am use shader animated. WHYYYY!
    type. upload_2023-2-7_23-42-42.png upload_2023-2-7_23-43-11.png upload_2023-2-7_23-43-46.png upload_2023-2-7_23-43-59.png
     
  42. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    thank you for the recent update!!!!! hope more people come onboard!!1
     
    JRRReynolds likes this.
  43. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    welp

    this is broken now



    I think I'm going to retire from unity for awhile
     
  44. miraycalskn

    miraycalskn

    Joined:
    Jun 28, 2020
    Posts:
    10
    I used older versions with some bugs but at least they were useable. But it seems like 2.0.31 completely broke the package LOL. Can't use Snapshot mode, don't even think about Shader mode. Agreed with @darkwingfart
     

    Attached Files:

  45. miraycalskn

    miraycalskn

    Joined:
    Jun 28, 2020
    Posts:
    10
    I found the issue :D If you are using Editor => Enter Play Mode Settings in project settings just uncheck it :D It fixes the issue :D
     
    hopeful likes this.
  46. miraycalskn

    miraycalskn

    Joined:
    Jun 28, 2020
    Posts:
    10
    Damn it's so ridiculous idk how many hours i spent on it :) (Just a little note : Never ever ever mess with animations list in runtime EVER just a friendly suggestion :))
     
    Last edited: Jun 10, 2023