Search Unity

Mesh Animator - Highly efficient animated crowds, fully animated GPU instancing, and more!

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

  1. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    I'm assuming that it is related to the transform of the mesh when it was exported from the authoring package. It's transformations probably were not frozen. Similar to this problem, only dealing with positioning rather than default pivot.

    https://forum.unity3d.com/threads/m...nstancing-and-more.284377/page-5#post-2996689
     
  2. egoquat

    egoquat

    Joined:
    Jul 4, 2012
    Posts:
    80
    I got an "GetObject failed to find.." error so non-baked using meshanimator tool on my owned .fbx file.
    I hope that your response for solve this error issue ASAP plz.

    error fbx file here:
    https://drive.google.com/open?id=0B6mBOdq62NS3UTh6QVdDcjhsZkk

    error occurred here:
    AssetDatabase.ImportAsset(changed.Key, ImportAssetOptions.ForceUpdate);

    error log:
    GetObject failed to find Object for Library Representation
    UnityEditor.AssetDatabase:ImportAsset(String, ImportAssetOptions)
    <CreateSnapshots>c__AnonStorey0:<>m__2() (at Assets/MeshAnimator/Editor/MeshAnimationCreator.cs:293)
    UnityEditor.EditorApplication:Internal_CallDelayFunctions()
     
  3. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    The asset baked correctly for me, though 2300 frames is not ideal to bake in Mesh Animator. I recommend you split the idles up into multiple clips if you aren't already.

    The error sounds like some kind of file path parsing error. What is the directory structure of where that file is located in your project? (Assets/Models/etc.../)
     
    egoquat likes this.
  4. Carterryan1990

    Carterryan1990

    Joined:
    Dec 29, 2016
    Posts:
    76
    Hey there i just purchased your asset and im having some trouble understanding it. After baking my animation, the prefab is made, do i use this prefab as my new prefab? Or do i use the original one that i used to bake with? Thanks! Also, if it is the prefab made form baking, can that prefab animation be used with the navmeshcomponent? thanks alot i really hope i can get this working for my project!
     
  5. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    You can either use the new prefab, or parent it to your existing prefab if you already have something setup. Just remove the old SkinnedMeshRenderer and Animator. There's no reason it shouldn't work with any other component as well, such as a NavMesh Agent
     
  6. VrTechEx

    VrTechEx

    Joined:
    Aug 4, 2013
    Posts:
    34
    Is this support sprite renderer :D? Thanks !
     
  7. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Hi,
    Your tool use now the GPU instancing, that mean DX11/12.
    Does it's still works on DX9 (Windows Desktop with no GPU features)?
     
  8. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    No, it only supports MeshRenderer and SkinnedMeshRenderer
     
    Last edited: Jul 10, 2017
  9. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Yes. GPU instancing is a feature of Unity through instance shaders, not a function of this asset. It works however because of how the asset functions in displaying non-skinned meshes, thus allowing them to be instanced in the shader.

    So as long as your shader supports both instancing and non-instancing, it will work just fine.
     
  10. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Hey everyone, I've made a short demo showing whats possible in Mesh Animator! 10,000 fully 3D, independently animated zombies!! Let me know what features you would like added to the next release!
     
    blitzvb, hopeful and ZJP like this.
  11. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
  12. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    1,007
    That looks great. I need hordes in VR. Is that possible with this asset? Also, is the zombie scene you posted included in the asset? Would suffice for a quick test.
     
  13. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    The zombie scene is not included in the asset. I just created it to show what the asset can do. But Mesh Animator will definitely help with rendering large hordes in VR though.
     
  14. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    526
    can i apply on this hordes a working AI too ? or the horde is just for esthetic purposes
     
  15. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Each mesh is its own transform and can be moved around however you wish. The asset simply handles the animation and rendering of each mesh, everything else is left up to you.
     
  16. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    526
    is there any chance to make an AI example for zombie hord
     
    Rowlan likes this.
  17. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    For the zombies in the video example I posted, I'm just using Unity's built in navigation system and NavMeshAgent class. Here's a tutorial on that system if you need one:
    https://unity3d.com/learn/tutorials/topics/navigation/navmesh-agent

    I'm just slowly moving all the zombies randomly around the scene for the sake of demo purposes. But with Mesh Animator, you're able to render and animate far more characters than with Mecanim and a SkinnedMeshRenderer.
     
  18. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
    Hello, yesterday I bought Mesh Animator in the asset store and today I have been testing the asset a bit. The fact is that I bought it because I wanted to improve the performance of the audience in a scene but I get lower performance using mesh animator than using the original model with Animator and Lods.

    Even reducing the mesh quality in Mesh Animator to the minimum I still have poor performance. Is this normal? Thank you.
     
  19. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Hey Bitboys, thanks for the support! And no that shouldn't be the case, I haven't seen an instance where a traditional Animator outperforms Mesh Animator. Could you PM me the asset (or if possible your whole setup) so I can take a closer look?
     
  20. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
    Hello, thanks for your answer, it will be difficult to send you the whole project because it´s so big! But i´ll try to make some screenshots for you and will send you a pm asap. Thanks!
     
  21. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    1,007
    I really would love to see better examples. Like animals running and flying around. Or lots of fish. The stadium scene is boring, without any action. All the gameobjects have animations that are cut off. It's not good for demonstration in my opinion.

    Some hordes moving around would be great for quick prototyping and finding out whether to use this asset or not.

    What I really don't like when I buy assets is that on the store page there are pictures and videos of things which aren't included in the asset. Without mention that you won't get this if you buy this.
     
  22. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Thanks for the suggestion! I'll see what I can whip up. :)
     
    Rowlan likes this.
  23. sentar

    sentar

    Joined:
    Feb 27, 2017
    Posts:
    33
    Hi jschieck,

    I'm having issues understanding how to implament a controller script with your mesh animator. I seen your documentation on playing animation; however, there not in an actual example script (besides your switch case).

    What I'm trying to learn is changing animation when the AI moves. I got my transform down and added your fsb.animator at the top. But can't get the actual walk/other aims to work (besides idle). Any help is much appreciated.

    Sincerely,
    Sentar
     
    Rowlan likes this.
  24. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    598
    Although i havnt tested with the new unity navmesh system, i just did a check to see the navmesh agents speed and played the appropriate animation ( idle , walk, run).

    In general this works fine for distant ai. I would advise switching to unity's mecanim(using lod system) for close up ai as the blending of animations looks much better.
     
  25. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    598
    Forgot i posted this sometime back its for an older version but gives you an idea anyway.
     
  26. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Hey Sentar,

    Below is a simple example controller.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using FSG.MeshAnimator;
    4.  
    5. [RequireComponent(typeof(MeshAnimator))]
    6. [RequireComponent(typeof(NavMeshAgent))]
    7. public class SimpleControllerExample : MonoBehaviour
    8. {
    9.     public string idleAnimationName = "idle";
    10.     public string walkAnimationName = "walk";
    11.     public float walkThresholdSpeed = 0.1f;
    12.  
    13.     private MeshAnimator meshAnimator;
    14.     private NavMeshAgent agent;
    15.     private Transform target;
    16.  
    17.     private void Awake()
    18.     {
    19.         // cache components
    20.         meshAnimator = GetComponent<MeshAnimator>();
    21.         agent = GetComponent<NavMeshAgent>();
    22.     }
    23.     private void Update()
    24.     {
    25.         // chase a target if it has one
    26.         if (target != null)
    27.         {
    28.             agent.SetDestination(target.position);
    29.         }
    30.         // if velocity is below the threshold, play the idle animation
    31.         if (agent.velocity.sqrMagnitude < walkThresholdSpeed)
    32.         {
    33.             if (meshAnimator.currentAnimation.animationName != idleAnimationName)
    34.                 meshAnimator.Play(idleAnimationName);
    35.         }
    36.         else // otherwise play the walk animation
    37.         {
    38.             if (meshAnimator.currentAnimation.animationName != walkAnimationName)
    39.                 meshAnimator.Play(walkAnimationName);
    40.         }
    41.     }
    42.     /// <summary>
    43.     /// Moves the agent to a position
    44.     /// </summary>
    45.     /// <param name="target">Target position</param>
    46.     public void MoveToPosition(Vector3 target)
    47.     {
    48.         agent.SetDestination(target);
    49.     }
    50.     /// <summary>
    51.     /// Sets a target transform for the agent to follow
    52.     /// </summary>
    53.     /// <param name="targetTransform">The transform to follow</param>
    54.     public void FollowTarget(Transform targetTransform)
    55.     {
    56.         target = targetTransform;
    57.     }
    58. }
     
    sentar, Rowlan and JBR-games like this.
  27. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
    Hello, I had a moment to test the asset carefully and this has been the result, the same as when I wrote here a few days ago.
    I have even tried with all the meshes with the same material and the same animation but I get the same result. I can not reach more than 25 fps.
    The meshes of the image have the shadows and blend probes disabled and I have also tried to mark them all as static but it has not been useful at all.
    I tested on a Pc with an Intel i7 processor, 32 ram and a Gtx 1070 graphics card.

    I might be doing something wrong, if so, please help me! I would like to be able to implement your asset in my project. Thank you.


     
  28. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    What is the polygon count of the meshes?
     
  29. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
    15,755
     
  30. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    That's most likely the reason why it's performing so slow. It's also going to consume lots of CPU time swapping out frames, and massive amounts of memory storing all the frames with that many vertices. I'm estimating around 60MB for each second of baked animation. And it's displaying 13 million triangles, that's going to tax any system. If you haven't already, take a look at the memory section of the documentation: http://jacobschieck.com/projects/meshanimator/documentation/documentation.html#memory

    I'd recommend making a lower-poly version of the model to use in the crowd. Or use a something like Krabl Mesh Processor to do it for you automatically.
     
  31. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
    Do I have to buy another asset to reduce the size of my model? Where in the description of your asset does it indicate that there is a polygons limit for models that can be used with mesh animator?
     
  32. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    No it's not required you buy another asset, you could do the modeling work yourself. Again, in the memory section of the documentation it outlines what the system is good for, and what it is not. What you're trying to accomplish is a perfect use for Mesh Animator, but you also have to understand that it's not going to magically make it run at 60fps if you are feeding it assets that aren't optimized.
     
  33. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
    That's the reason I bought Mesh Animator ...
    To optimize my project.
     
  34. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    And it will help you get there, but displaying 13 million triangles for a crowd isn't a possibility on modern hardware. Look at recent AAA titles and what they do:

    Mario Kart 8 still uses billboards


    Rocket League uses spheres animated through a vertex shader


    Forza still uses billboards


    Even if this isn't for a game, you need to still exercise good practices. You can easily display as many characters as you are trying to using Mesh Animator, you just need to reduce the polygon count.
     
  35. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146

    Of course man, my in-game crowd are sprite billboards like in Arms game and works nice but i want to use Mesh Animator to render the "fake" audience before the game starts. Do you understand what i mean?
     
  36. Mijail_Bitboys

    Mijail_Bitboys

    Joined:
    Apr 22, 2015
    Posts:
    146
  37. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Well I wasn't suggesting using billboards in replacement for the other crowd scene, just using them as examples. Send me a PM and we can discuss how to get it running smoothly further.
     
    Mijail_Bitboys likes this.
  38. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    598
    Last edited: Jul 28, 2017
  39. sentar

    sentar

    Joined:
    Feb 27, 2017
    Posts:
    33
    Hey jschieck,

    Thank you for the example ai scirpt! I was able to reference yours and it went well to my AI needs! :)

    I have another question for you if you don't mind.

    What is a good practice to having a variety of weapons attached to AI using mesh animator?

    I plan on giving AI commands to change out weapons on the fly. Would I need to make several AI being children of one gameobject and just hide/show each one as the command is giving out to change weapons? or can I somehow attach weapons to one AI and make it fit in?

    Any help would be appreciated.

    Sincerely,
    Sentar
     
  40. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    You could do that. Or have a public GameObject[] on your controller script that has a list of all your weapon prefabs and instantiate them and parent them to your exposed bone transform as needed.
     
    JBR-games likes this.
  41. sentar

    sentar

    Joined:
    Feb 27, 2017
    Posts:
    33
    "exposed bone transform" on a baked mesh animator AI with everything as a base mesh except for the weapon/shield?
     
  42. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    BTW, does it's works with/from an model with legacy animation (not Mecacim)?
     
  43. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Yes it works with all 3 types: Legacy, Generic, and Humanoid.
     
    ZJP likes this.
  44. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Yeah I'd leave the "weapon" or "hand" bone exposed on the baked mesh. Then parent your interchangeable weapons/shields/etc... to that.
     
  45. sentar

    sentar

    Joined:
    Feb 27, 2017
    Posts:
    33
    Unfortunately when adding the weapons/shields etc. to my exposed bone it seems to be off as far as going through the full animation.

    The mesh will go through the animation; however, the weapon/shield do not position themselves all the way through to match the mesh. :(

    Here is an example screen of when I applied the weapons with baking, and exposed the hand bone. The hand bone does not go with the mesh at all (capsule collider).

    No matter what I do it won't change. Any thoughts?

    upload_2017-8-9_1-58-4.png

    I have also manually added in the weapons to the hand bone, and it will make the axe be where the collider is...

    What am I doing wrong?
     
  46. sentar

    sentar

    Joined:
    Feb 27, 2017
    Posts:
    33
    It appears the "apply to transform" works and is probably the missing link. My apologize. I thought I could bake the meshes etc. and have the functionality/efficiency.

    Once again my apologize for being the novice. :)
     
  47. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    85
    mesh.Optimize() (line 1178 in MeshAnimationCreator) is removed in Unity 2017, so this asset is not currently supporting Unity 2017. Is there an alternative to this or is it really necessary?
     
  48. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    It appears it's no longer necessary and an editor only optimization, I'll put a fix out ASAP. For the time being you can just remove that line.
     
  49. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    369
    Version 1.5.2.4 has been submitted for approval, it contains the following fixes: (big shout out to Marko for helping with root motion issues)

    Version 1.5.2.4
    Fixed 2017.1 Mesh.Optimize API issue
    Fixed root motion not being applied on skipped frames
    Fixed root motion not working correctly at lower FPS LODs

    1.5.2.3 was approved within a day or two so look for it to be available later this week.

    Version 1.5.2.3
    Added batch baking feature.
    Fixed exposed transforms not being positioned properly in the hierarchy, and their rotations during playback.
     
  50. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    85
    Thanks for the quick work! I've already commented it out, I figured it was probably unneccesary. I assumed if Unity deleted the method and didn't provide an alternative that it would correctly be obsolete.

    Figured right this time. Rare to happen in the software world lol.
     
unityunity