Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Replied to you via email. I'll be submitting a new version to the asset store that supports all aspects of root motion baking.
     
  2. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Many thanks. I am still getting Root motion when I dont ask for it in the amended build, but all else is well.

    Will play with the settings. see if I can figure it out.

    A screenshot of the settings you used would be great. email is fine.

    Thanks again
     
  3. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    impressive idea about compression
     
  4. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i finaly buy it
    first try
     
  5. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    ok it's working second try i win 15 fps with 50 player

    any idea how keep setup the fx move like trail render on attaque move

    please i got this happen


    IndexOutOfRangeException: Array index is out of range.
    MeshAnimation.GenerateFrameIfNeeded (UnityEngine.Mesh baseMesh, Int32 frame) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:77)
    MeshAnimator.UpdateFrameInvoked () (at Assets/MeshAnimator/Scripts/MeshAnimator.cs:234)
     
    Last edited: Oct 5, 2015
  6. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey kilik128, any chance you could email or PM the object you're trying to bake and I can take a look for you?
     
  7. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Nice...
     
    twobob and hopeful like this.
  8. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Haha you found the video for the new version before it got approved in the Asset Store! Just a little sneak peek of what is to come! New version should be out later this week.
     
    hopeful likes this.
  9. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Version 1.3.0 is out!
    With this new version it is now possible to take any number of Mesh Filters and/or Skinned Meshes and bake them into a single object for even better performance and combined draw calls!

    Changes:
    You can now bake multiple meshes into a single Mesh Animator mesh.
    Support for Web GL builds, though threaded crossfading is disabled.
    Even more performance improvements!
    New crowd example and mesh combination examples (see below).

     
  10. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    Wow Jacob, thanks for improving this asset even further :D
     
  11. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Changes:
    You can now bake multiple meshes into a single Mesh Animator mesh.

    would you mind going into a little bit more detail about this, for example with this be ideal for say loD levels ? so all levels would use one mesh animator component ? would it bake one run animation for all meshes?
    Thanks and great product by the way
     
  12. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    No it doesn't work like that, but that's an interesting idea that i could investigate, as I've been wanted to implement LOD's into this system for awhile.

    What baking multiple meshes into a single mesh means is that you can take any number of mesh filters and/or skinned meshes and bake them together to only get a single draw call. So for example, a character and it's weapon and it's armor could be baked into a single mesh. Or if you had a large group of meshes each with their own animations, like 200 trees each with a different animation, and wanted to combine them all into a single animated mesh, you could do that.

    It's greatly beneficial when trying to reduce draw calls and combining large amounts of animated assets into a single mesh. In the current version, all combined meshes need to be atlased onto the same texture and share the same material, but I'm trying to remove these limitations for the next release.
     
    twobob likes this.
  13. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Ok i got ya.
    I haven't downloaded the new version yet. and didn't see anything in the docs referring to how to do this, so how would you bake say 50 trees together would they all just need to be a child of one object ? would each tree have an animation on it, or a new single animation for all combined meshes?

    thanks again
     
  14. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Correct you would parent all the trees together and then have 1 animation for all of them. Or animate them in your 3D package seperately, export an FBX, then combine them using Mesh Animator.
     
  15. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
  16. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @jschieck just downloaded v1.3 to test it out and i'm having an issue. seems that there is no mesh being generated so when i hit play the model basically disappears. the meshes are changing like they should be in the mesh filter. but if i click on one they are blank.
    https://www.dropbox.com/s/smyd3dnf05sckzx/issue Mesh_Animator.PNG?dl=0

    Windows7 64 with unity 5.2.1f1

    Note: i got an older version from another project and reimported it into my project and it works fine. so for now ill keep using that until we can figure out my issue.
    Also would it be possible in some future update to possibly have the collider locations bake with the mesh? or would it be possible to attach colliders to vertice on the mesh maybe, Sure be nice for hit detection since we lose the bones they would normally be attached to.
    thanks
     
    Last edited: Oct 27, 2015
  17. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey great demo! Are you trying to combine multiple meshes when it's breaking or just converting one mesh? If I had the mesh I could investigate the issue better.

    Also for attaching colliders, you can make an empty GameObject with a collider attached, and use the the AttachObjectToFace script included in the project to have it follow a face on your baked mesh.
     
  18. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    I didnt even think about testing the attachObjectsToFace.cs. sounds like that may do the job.
    just converting a single mesh for now. Ill send you a copy of the mesh to have a look at it,When i get off work this evening. Only thing i didnt try was baking the mesh in a clean project .
    Thanks
     
  19. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @jschieck I've been trying to get the animations to match speed of the character a little bit better. So i tried setting the animation speed relative to the character speed. It seems that changing the animation speed during the animation ,resets the animation. Is that correct or am i going about something wrong. could that be something changed in the next update ?

    Loving the fact that i got a ton of enemies running around in my game while still maintaining great frame rate...
    I Am absolutely blown away that more people haven't bought this, Especially for mobile development considering animated skinned meshes are one of the biggest frame rate killers on mobile devices
    Thanks.
     
    Last edited: Nov 15, 2015
  20. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey @JBR games , I've tested out changing the speed at runtime and it seems to be working as expected. Are you sure you're changing the speed on the MeshAnimator component and not the MeshAnimation object? I used this simple script to test it, it just oscillates between 1 and 0 speed.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SpeedModifier : MonoBehaviour
    5. {
    6.     void Update ()
    7.     {
    8.         GetComponent<MeshAnimator>().speed = Mathf.Sin(Time.time) * 0.5f + 0.5f;
    9.     }
    10. }
     
  21. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    yep that was it, I was trying to set the animation speed and not the mesh animator.speed .Thanks again sorry for the dumb questions. For anyone using navmesh agent here is the basics of what im doing. Hope its helpful..
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class JBR_MeshAnimator_Controller : MonoBehaviour {
    6.  
    7.     private MeshAnimator meshAnimator;  //mesh animator component
    8.     public NavMeshAgent navAgent;        // if using a navmesh agent add it here
    9.     private float navAgentCurSpeed;        // current speed of navmesh agent
    10.     private float topSpeed;                //nav agents speed
    11.     public float transitionSpeed = .75f; // speed at which to transition from  walk to run Animation
    12.     public string curAnimation;            //last animation started
    13.     public float updateSpeed = 0.2f;        //how often animation data is checked, at .2 update 5 times a second ,   in most cases there is no need to check this everyframe.
    14.     public string MA_Walk;  //add the correct name for the walk animation here, this animation should be set to loop
    15.     public string MA_Run;    //add the correct name for the run animation here, this animation should be set to loop
    16. void Awake()
    17. {
    18.      navAgent = this.gameObject.GetComponentInParent<NavMeshAgent> ();
    19.      meshAnimator = this.gameObject.GetComponent<MeshAnimator> ();
    20. }
    21. void OnEnable()
    22.     {
    23.      topSpeed= navAgent.speed;  //max speed of navmesh agent
    24.      InvokeRepeating ("SlowUpdate", updateSpeed, updateSpeed);
    25. }
    26. void SlowUpdate()
    27. {
    28.     curAnimation = meshAnimator.currentAnimation.ToString ();// last animation started
    29.     navAgentCurSpeed = navAgent.velocity.magnitude;    //current speed of navmesh agent
    30.  
    31. if (navAgentCurSpeed <= transitionSpeed)
    32. {
    33.    if (curAnimation == "Zomb_Walk (MeshAnimation)") //if we are already using the correct animation ,only adjust the speed.
    34.   {
    35.      meshAnimator.speed = navAgentCurSpeed /transitionSpeed;
    36.   } else {     // we need to set the correct animation
    37.      meshAnimator.Play (MA_Walk);
    38.      meshAnimator.speed = navAgentCurSpeed /transitionSpeed;
    39.   }
    40. if (navAgentCurSpeed > transitionSpeed)
    41.   {
    42.     if (curAnimation == "Zomb_Run (MeshAnimation)")
    43.     {
    44.        meshAnimator.speed = navAgentCurSpeed /topSpeed;
    45.     } else {
    46.        meshAnimator.Crossfade (MA_Run , 0.25f );
    47.        meshAnimator.speed = navAgentCurSpeed /topSpeed;
    48.            }
    49.         }
    50.      }
    51. }
    52.  
    53.  
     
    Last edited: Nov 22, 2015
    twobob and hopeful like this.
  22. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    No problem! Glad it's working for you.
     
  23. niptiknah

    niptiknah

    Joined:
    Nov 22, 2015
    Posts:
    2
    Hi, I'm loving the speed increase, I'm using a set of models I bought from the asset store called HumanPack by Villains for Hire and running 500 hundred for a battle scene. I'm having an issue with the normals seeming wrong , its not lighting correctly , not the same as when just using the skinned mesh renderer. Are there any known issues, I will try and test with another model as some of the animation bones are scaled in that model and wondering if that could be affecting things.
     
  24. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Yeah I've seen that occasionally with some models. Working on a fix and will send you the new version.
     
    niptiknah likes this.
  25. niptiknah

    niptiknah

    Joined:
    Nov 22, 2015
    Posts:
    2
    Thanks that worked perfectly and thank you for such a speedy fix. Cheers :)
     
  26. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @jschieck thanks for the latest update, between that and/or the unity update my generic legacy models will bake as humanoid now :)
    I was curious if there is a way to automatically add (all animations in the project) to a bake and then uncheck only the ones i don't want. Maybe that's already possible and i just haven't figured out how to do it. I picked up a large amount of additional animations and its pretty tedious to manually add them one at a time.
    I'm thinking it would just be a few lines of code but its a bit above my knowledge level. Thanks..
     
  27. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Ok this seems to work well for adding custom animations without having to select one at a time, i had 85 to add haha..
    Code (CSharp):
    1. //add this script to your Animated character prefab in the scene, before you create a new Mesh Animator character
    2. //make sure all your custom animations are in a folder in the resource folder
    3. //the Animations will automatically be added to your List of animations to bake
    4.  
    5.  
    6.  
    7. using UnityEngine;
    8. using System.Collections;
    9.  
    10. [ExecuteInEditMode]
    11. public class JBR_AnimationsList : MonoBehaviour {
    12.  
    13.  
    14.     public AnimationClip[] animationClips; //array of animation clips
    15.     // Use this for initialization
    16.     void Start () {
    17.         animationClips = Resources.LoadAll<AnimationClip>("_Animations"); // **(_Animations)** this is the name of the folder you have all your animations in, add it to the Resources folder .
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update () {
    22.  
    23.     }
    24. }
     
  28. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    A easier way to do it would be to add a button that adds all selected clips to the array. Add this code to the MeshAnimationCreator.cs script at line 200. I'll include this addition into the next release.
    Code (csharp):
    1. if (GUILayout.Button("Add Selected Animation Clips"))
    2. {
    3.     foreach (var o in Selection.objects)
    4.     {
    5.         if (o is AnimationClip)
    6.             customClips.Add((AnimationClip)o);
    7.     }
    8. }
     
    JBR-games likes this.
  29. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @jschieck So i used one of my current characters with the FPS Mesh tool. it basically fragments the character into having separate materials(submeshes) when i bake the character in the current version of Mesh Animator it no longer has the extra (submeshes). Do you think this is an issues with how FPS Mesh tool is making the submeshes? Mesh Animator does seem to bake correctly with an older version of mesh animator i have but not the current.
    https://www.dropbox.com/s/7o3i20tvez1z2x7/MA_FPS_Mesh_subMesh.PNG?dl=0
     
  30. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Yeah that's a known issue with sub-meshes, I was unable to get it working for the current version. I'm working on fixing it for the next version.

    One thing you could try, since it's only a single mesh, is replacing the Mesh Filter and Base Mesh fields on the Prefab with your original mesh, since vertex order should be the same, it should still work. Then you'd have all the proper sub-meshes, and it might still animate correctly.
     
  31. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Ok Thanks for the info, I posted it more to let you know.
    I should be ok as my older version of MA (pre Multi-object) seems to bake it ok still.
     
  32. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Will this asset work with SVG Assets which are meshes created by SVG Importer?
     
  33. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    Oh my god, this asset looks absolutely perfect for my game Stage Presence - I've been trying really hard to improve the performance of the crowd which is all skinned mesh renderers for some time now. I can't believe I've only just discovered this asset. I've just purchased it and will integrate it into my project over the next few days. If things work out I'll definitely be leaving a 5 star review :)
     
    hopeful likes this.
  34. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I'm not entirely sure, but assuming they are normal Unity meshes, and use either a Mesh Filter or Skinned Mesh Renderer then it should work.
     
  35. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Glad to hear it! Hope it works for you!
     
  36. little_bunny

    little_bunny

    Joined:
    Dec 12, 2015
    Posts:
    5
    @jschieck
    I buy this plugins at 2016.1.15, It's not work, in unity 4.6.9f1 or all the unity version
    I drag the prefab in Example/Player/Player_AnimatedMesh into the Hierarchy window, and Run
    so many error message appeared in Console window:

    NullReferenceException: Object reference not set to an instance of an object
    DeltaCompressedFrameData.op_Implicit (.DeltaCompressedFrameData s) (at Assets/MeshAnimator/Scripts/MeshFrameData.cs:98)
    MeshAnimation.get_frameData () (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:26)
    MeshAnimation.GenerateFrame (UnityEngine.Mesh baseMesh, Int32 frame) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:158)
    MeshAnimation.GenerateFrameIfNeeded (UnityEngine.Mesh baseMesh, Int32 frame) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:93)
    MeshAnimator.OnEnable () (at Assets/MeshAnimator/Scripts/MeshAnimator.cs:124)


    I notice that you update the version1.3.3 at 2016.1.14, maybe there's something wrong.
     
    Last edited: Jan 15, 2016
  37. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I've PMed you a fix, I'll fix the issue with 4.6 versions in the next update. For anyone else with this issue, simply add

    || UNITY_4_6

    to the top of MeshFrameData.cs
     
  38. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey everyone, I've just submitted version 1.4.0 with lots of new performance updates as well as a new LOD system to get even better FPS!



    Version 1.4.0
    New LOD system that allows for meshes to dynamically change the playback FPS depending on the distance from the camera. It can be set to transition as gradual as you like.
    Normal calculation for the runtime meshes can either be set to fast mode (built-in) or specify a custom smoothing angle (slower, but runs on a different thread)
    Several other bug fixes that you guys have been so graciously reporting, keep em' coming!
     
  39. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    @jschieck
    Great update..

    If i already have a system in place for checking lod levels ( no sense in having 2 systems do the same calculations for 100s-1000s of characters) can i just set a lod level for it to play ? Like.. MeshAnimator.Lodlevel (1);

    Thanks
     
  40. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    @jschieck awesome update. I sent you an email about the performance. And, you improve it withins couple days :) Awesome support!!! I like the option to set a LOD level also. I will do some tests soon on Android, and let you know soon.
     
  41. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    @jschieck fantastic update!

    Just to add to the chorus of compliments, I'd like to thank you again for your support and handling my emails and bug reports so promptly; 20 minutes between an email and a bug fix in one instance! That's amazing support for an asset, if I could leave a second 5 star review I would!
     
  42. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I didn't think of that, but I'll go ahead and add it to the next version. If you don't add any LOD levels it won't do any distance checking so you won't lose any performance. Even if you add it, it's only a single Vector3 operation every time an animation frame is updated, so it's relatively cheap.

    Thanks for all the praise guys! Honestly most of the improvements come from all of you sending me bug reports and requests, so keep em coming!
     
    twobob, ikemen_blueD and JBR-games like this.
  43. lucien.beaujouan

    lucien.beaujouan

    Joined:
    Nov 9, 2015
    Posts:
    3
    Hi, first, thanks for you script, it is really a savior. Secondly, I have the same problem as Niptiknah, some of the faces on my mesh are not rendering well. Is the fix still available ? What could cause that problem to occur ? (I plan on using your plugin a lot, so it would be nice if I could avoid this problem).

    Thanks by advance, and keep the good work !
     
  44. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    The fix is implemented in the latest version 1.4.0, which is awaiting approval for the asset store (should be any day now).
     
  45. lucien.beaujouan

    lucien.beaujouan

    Joined:
    Nov 9, 2015
    Posts:
    3
    That's perfect ! Thanks a lot, I'm waiting for it now
     
  46. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It's now available for download in the asset store!
     
    JBR-games likes this.
  47. lucien.beaujouan

    lucien.beaujouan

    Joined:
    Nov 9, 2015
    Posts:
    3
    Thanks a lot, it worked perfectly, everything now looks good.
    As for an exemple, I'm posting an image of before/after Mesh Animator.
    Left : 1050 chickens w/o Mesh Animator
    Right : 1200 chickens with Mesh Animator
    Difference : 45 fps ! Everybody should have it !

    So thanks again, and keep it going !
     

    Attached Files:

    JBR-games, hopeful and jschieck like this.
  48. blackanub1s

    blackanub1s

    Joined:
    Dec 12, 2013
    Posts:
    21
    Hi,

    I have a problem with textures. How to fix it?



    Sorry for my english, i'm french.

    Thanks by advance, good job.
     
  49. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I can't seem to see the image. Re-upload it?
     
  50. blackanub1s

    blackanub1s

    Joined:
    Dec 12, 2013
    Posts:
    21
    thanks for your interest.

    You can find the image attached.
     

    Attached Files: