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. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It does not support layers, because all knowledge of weights is lost in the bake. The system simply makes a snapshot of vertex positions of each frame, and there's currently no way to mask that during bake time to be applied later. Sorry.
     
  2. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    That sounds very reasonable, thanks clearing that up. Dont get me wrong, this is a WONDERFUL asset, giving my product a value I never dreamed I could imagine as an indie developer. It's just, that there doesnt seem to be a single umbrella holding animation set (idle, walking, etc.) on the whole internet...
     
    twobob likes this.
  3. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Awesome asset! Perfect for what I need.

    However, I get compile errors upon import:

    "Assets/MeshAnimator/Example/Scripts/AnimatorStateMachine.cs(11,22): error CS0019: Operator `+=' cannot be applied to operands of type `Action<string>' and `method group'"


    Running Unity 5.4.0

    When I simply delete the Examples folder I start to see more errors:

    Assets/MeshAnimator/Scripts/MeshAnimator.cs(202,42): error CS1955: The member `MeshAnimator.OnVisibilityChanged' cannot be used as method or delegate


    This line: if (OnVisibilityChanged != null) OnVisibilityChanged(isVisible);


    Assets/MeshAnimator/Scripts/MeshAnimator.cs(414,17): error CS1955: The member `MeshAnimator.OnAnimationFinished' cannot be used as method or delegate

    This line: OnAnimationFinished(cAnim.animationName);
     
    Last edited: Mar 15, 2017
  4. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hmmm, I've tested the asset in that version of Unity and am not seeing the errors. It's possible that some other scripts in the project are conflicting with Mesh Animator?

    Is that first error the only one that shows up when you first import the asset?
     
  5. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Hi.

    Yes that is the 1st error I get and the only one.

    I do get this warning though:

    There are inconsistent line endings in the 'Assets/MeshAnimator/Scripts/Utilities/MatrixUtils.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.

    But fixed it in mono.

    It's a big project with lots of assets.

    Short of deleting assets (which I will try if I must) is there another way to solve these import problems which I have seen before with other assets?

    Why would any asset conflict with another?

    This has always baffled me.
     
    Last edited: Mar 15, 2017
  6. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It's possible another script defines something called "Action" judging off of the errors or something along those lines. You could try changing the three lines in MeshAnimator.cs 107-109 to:
    Code (CSharp):
    1.  
    2.     public System.Action<string> OnAnimationFinished;
    3.     public System.Action OnFrameUpdated;
    4.     public System.Action<bool> OnVisibilityChanged;
    To explicitly define those types.
     
    jococo likes this.
  7. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    That cleared it up!! Awesome and thanks for such a quick reply :)
     
  8. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    @jschieck I got a weird lying initial pose when I bake a skinned mesh only. Everything works fine in my quick test cases if I bake a Skinned Mesh with a Mesh Filter. So, I suspect something wrong with the Sub-Meshes bake new feature. I sent you an email along with my project. I'm looking forward to hear your helps soon :)
     
  9. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Replied with fixes for you ;)
     
  10. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    My skinned mesh is rotated on its front face and is scaled smaller from the original by about 40% after converting the anims.

    When I play the anims it scales up correct and rotates to be correct.

    I'm using Generic rig
     
  11. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    This is a common problem that people have after baking. It happens because the mesh is not oriented or scaled correctly in the source FBX. Typically it has the Z axis facing up, so when it gets put into a MeshFilter component, without any skinned weight information, it faces downwards since Unity is a Z forward application.

    You can fix it by opening your rig, reorienting the mesh's rotational axis so that Z is facing forward, then re-exporting. As far as playback, it won't have any effect if you leave it as is, but looks strange visually.
     
    jococo and ikemen_blueD like this.
  12. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    Hi, I manage to fix the Z axis facing up issue. Thanks for you helps. Btw, I notice shader a bit weird when updating with sub-meshes. I will let you know if I found any problems.
     
  13. EthanHunt

    EthanHunt

    Joined:
    Oct 9, 2012
    Posts:
    14
    Hey there, I have a few problems with this tool:
    • The generated mesh has terrible normals, even with highest quality settings I can get. How can I preserve normals/tangents?
    • The exposed transforms have strange rotations when the animations are running. They are not stable at all, and thus attaching anything to them looks completely wrong. For example I need to attach boxes under bones to represent hitboxes, they moved correctly with mecanim, and fly all over the place with MeshAnimator. That renders them useless.
    • The editor doesn't remember the settings I used to bake a particular asset/prefab. This is a small annoyance, but would be good to get it fixed.
     
  14. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey Ethan,

    Could you possibly send me the asset you are baking, so I can look into why it's giving you such strange results? Send it to jschieck@gmail.com or PM me a link.
     
  15. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    I encounter a weird bug. The baked animation sometimes just stops playing for a while, for unknown reasons. If I click to disable and enable Mesh Animator component, the animation starts to play again. No errors on the Console though. It's hard to make this bug to send you the project. Current Frame stuck at frame-0.
     
  16. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Is it possible that the MeshAnimation object isn't set to Loop for WrapMode?
     
  17. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    the MeshAnimation object is set to Loop for Wrap Mode. Actually, if I wait for like 2 minutes, the animation will start. But, if I check then uncheck Mesh Animator, the animation starts immediately. The baked animation works fine. But, I notice after a while, the animation starts to get stuck. I suspect something wrong with the Tick update logic, like Base Mesh of a frame not ready or something pauses it.
     
  18. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    108
    I have a problem with one of my MeshAnimators. I use the MecanimMeshAnimatorController script for compatibility reasons. It works, except for one newly created prefab. With this one I can see that the right animation is played (in the animator window) but the model keeps playing the default animation.

    The only differende I can see is, that the new prefab has a mesh attached to one bone. There are no errors or warnings. I can Play the MeshAnimator Animation manually though (by declaring as default).
     
    Last edited: Mar 23, 2017
  19. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey Henry,

    Does the name of the state in Mecanim Animator match the name of the baked animation? The two names must match exactly for that controller to work. If not, rename the state in the Animator to match the name of the baked animation.
     
  20. jbooker410

    jbooker410

    Joined:
    Mar 9, 2014
    Posts:
    41
    I have a few questions before I purchase. Would it be fairly easy to code a switch over to a regular mecanim character when you get close to it and I am working on a VR game for which I have to use the lab render shader on the mesh renderer which from reading I'm not sure if your plugin uses the mesh renderer like normal meshes? Thanks
     
  21. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    You can use Unity's built-in LOD system to swap out for a different asset completely if you'd like. MeshAnimator also uses a MeshRenderer, it swaps the mesh displayed to display the animation (like a 3D sprite-sheet). I go into a bit more detail in this post:

    https://forum.unity3d.com/threads/m...nstancing-and-more.284377/page-3#post-2644793

     
  22. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hi jschieck,

    I am having a problem getting a child object to match an exposed transform position in all animation states. For example, I have a soldier/footman in my game, and I want to attach a sword to his right hand. I exposed the right hand transform when baking, and placed the sword as a child gameobject under the exposed right hand transform.

    It works in the "Idle" animation position, but then when my soldier/footman is in the "Running" animation, the sword is out of place, and the transform doesn't match the hand well. Then when the soldier/footman goes back into the "Idle" animation, the transform snaps back into the original position.

    So to sum up, when the character is in the Idle state, the sword is in correct position. When in the Running state, the sword is not in the correct position.

    What may be causing this? Thank you.


    Edit: I figured out that I have to have the child sword object at a local position of (0, 0, 0), then this allows the sword to be in the correct position. But I still have the problem of the sword "snapping" back into position after the crossfading of the animations from one state to another.
     
    Last edited: Apr 3, 2017
  23. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I will look into the snapping of the positioning when crossfading and get back to you.
     
    Velo222 likes this.
  24. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Ok thank you. No big hurry really, I'm just working on it as a side project right now. :)
     
  25. govi627

    govi627

    Joined:
    Jan 30, 2013
    Posts:
    20
  26. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I've fixed this in the latest version, it's awaiting approval in the asset store.
    Thanks for the heads up!
     
    twobob likes this.
  27. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Awesome :)
     
  28. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Version 1.5.2 Released!
    The latest version is now available for download. Quite a few changes in this one.
    • Asset bake settings are now automatically saved and loaded.
    • Added FSG.MeshAnimator namespaces.
    • Added option to use the original mesh as the base mesh instead of creating a new one.
    • Fixed exposed transforms not moving while crossfading animations.
    • Minor bug fixes.
    • Updated documentation.
    Version 1.5.2.1 is awaiting approval which fixes this issue:
    • Fixed animation events near the start and end of animations being inconsistently fired at lower FPS.
    • Minor optimizations.
     
    twobob and Velo222 like this.
  29. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I was targeting WEBGL and got a:

    Assets/MeshAnimator/Scripts/MeshAnimator.cs(370,31) error CS0161:
    FSG.MeshAnimator.MeshAnimator.DequeAnimatorForCrossfade()
    Not all code paths return a value.

    So, I swtiched to standalone to do that bake. I kind of recall this from Version "Stone-age" the last time I used it on Webplayer... But for different reasons (with the same outcome)

    It is a pain to switch when you run with crunched assets, even with a cache up and running.
    Don't suppose, if you get a minute, you might consider taking pity on us poor second-cousin WEBGL users and have a look at that :)

    Many thanks. And hello from the past.
     
  30. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey sorry about that, I've fixed it and submitted an update.

    To fix temporarily, add
    Code (CSharp):
    1. #else
    2.             return null;
    3. #endif
    in MeshAnimator.cs line 378, and on line 502 change GenerateCrossfadeFrames(); to GenerateCrossfadeFrame();
     
    twobob likes this.
  31. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Thanks so much for this.

    I spent about the last 12 hours on and off - over three brand new projects - trying to figure out why SOME models don't "play" like the others. It's not any edits I made to any intermediate bits of the mesh (I downloaded totally fresh everything, twice)

    A real genuine headscratcher.
    I am trying to think of a way to LOOK at the created animations (Each frame) outside the "play" environment to see if the data "is there or not"

    Any clues or guidance gratefully accepted.
    And the models are like TUNA:SWIM and BASS:SWIM - nothing fancy. all tiny and no different from the ones that did convert that I can see? Dang !

    Heh ho.
    I am putting together a test project if you would like it

    I would very much appreciate to know more what "Use original Mesh" is supposed to do, as NOT selecting it (I.e. it is turned off) does not create a mesh prefab (That I found yet) as I expected so I am struggling to understand what it does.

    I thought it would make a complete mesh that contained all frames of the model in one central location like "shells" and then turn "on" the relevant shell (and all the others off) at the relevant time, that is how it works right?

    Thanks. I did read the manual - several times.
     
  32. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Yeah a test project would be the best way to help me to figure out what's going wrong for you.
     
  33. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    on that right now

    Removing Crunch format to save you some time and I have ruled that out as the cause
     
  34. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Version 1.5.2.2 has been submitted with the following fixes:
    • Fixed compile issues with WebGL.
    • Fixed issue baking legacy Animation components when they were not on the parent object.
     
  35. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Many thanks for this timely fix. hopefully our efforts here will save others time in the future.
    I tell myself that like almost every day it seems :)

    Hero
    Fishes Wiggly again. Superstar
     
  36. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    upload_2017-4-12_19-8-28.png

    touch of GPU instancing. Happy days. thanks man
     
  37. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Is there a way to batch/bulk process MeshAnimators? It's taking quite a bit of time to go through all of my models o.0
     
  38. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I'll put a better implementation into the next release, but for now, this should work. Add this to MeshAnimatorCreator.cs (line 147) inside of OnGUI() at the top.
    Code (CSharp):
    1. if (GUILayout.Button("Batch Bake Selected Objects"))
    2. {
    3.     previousPrefab = null;
    4.     foreach (var obj in Selection.gameObjects)
    5.     {
    6.         try
    7.         {
    8.             prefab = obj;
    9.             OnPrefabChanged();
    10.             var toBakeClips = GetClips();
    11.             foreach (var clip in toBakeClips)
    12.             {
    13.                 frameSkips[clip.name] = 1;
    14.             }
    15.             CreateSnapshots();
    16.         }
    17.         catch (System.Exception e)
    18.         {
    19.             Debug.LogException(e);
    20.         }
    21.     }
    22. }
    Then just select all your meshes/prefabs and click the batch bake button. If you want to stop it from creating the success dialogs after each mesh is baked, comment out line 800-801. You should be able to just walk away as it bakes!
    Code (CSharp):
    1. //EditorUtility.DisplayDialog("Mesh Animator", string.Format("Baked {0} animation{1} successfully!", clips.Count
    2. //                    , clips.Count > 1 ? "s" : string.Empty), "OK");
     
  39. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Thanks, worked like a charm! Made going through 50 bakes muuuch easier! I'm sure I'll have to do this a few times too, as I add more animations. I'll leave a review in a moment, thanks again!
     
  40. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    I'm having an issue with mesh animators after they are converted. The animations are wierd, look like this https://gfycat.com/LastingWelloffIcelandichorse
    and this error
    "
    Mesh.vertices is too small. The supplied vertex array has less vertices than are referenced by the triangles array.
    UnityEngine.Mesh:set_vertices(Vector3[])
    FSG.MeshAnimator.MeshAnimation:GenerateFrame(Mesh, Int32) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:272)
    FSG.MeshAnimator.MeshAnimation:GenerateFrames(Mesh) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:82)
    FSG.MeshAnimator.MeshAnimator:Start() (at Assets/MeshAnimator/Scripts/MeshAnimator.cs:160)"

    I'm using this asset, btw. https://www.assetstore.unity3d.com/en/#!/content/15126
     
  41. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Could you PM or email one of the characters and I'll look into it for you.
     
  42. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Hrm, probably shouldn't because they are paid assets. I'm going to give it another go later--I did get a couple of them to work, using a different mecanim controller. It might be something with that. I'll let you know if I find out anything. Probably at a minimum, I could send you the animator files, if that is what is allowing me to reproduce the problem.

    By the way, wanted to shoutout for your asset. It played a large part in doing my crowd AI system -- 10k ai's on PC right now, ~50-60fps.


    overhead view
    https://cdn.discordapp.com/attachments/85593628650504192/312233770772332544/unknown.png
     
  43. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I have a question regarding using mesh animator with skinned meshes and LOD.

    I want to have hordes of enemies where they are skinned meshes up close and then get replaced with mesh animator when far away. I didn't see an example of this. Is this possible? If so, how?
     
    ftejada likes this.
  44. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Yes this is possible. You can use Unity's built in LOD system for this. Have a look at this post that goes into a little more detail in Step 2.

    https://forum.unity3d.com/threads/m...nstancing-and-more.284377/page-3#post-2644793

     
  45. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I've implemented the LOD...but I'm now getting the below error. I've re-imported my model with "read/Write" enabled...not sure why I'm getting the error. The error happens on the MeshAnimator animatedMesh.

    Btw, I'm using Unity 5.6.1


    Not allowed to access vertices on mesh 'Enemy1_LOD3(Clone)' (isReadable is false; Read/Write must be enabled in import settings)
    UnityEngine.Mesh:set_vertices(Vector3[])
    MeshAnimation:GenerateFrame(Mesh, Int32) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:261)

    Also, just a side note. I believe in your product...as it has great reviews...but PLEASE make some youTube videos on how to set things up. It make things a lot easier :).
     
    Last edited: Jun 8, 2017
    ftejada likes this.
  46. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510

    It looks like the mesh I was using was the old NON writable mesh, somehow I screwed up :).....so the issue is now fixed!
     
  47. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Glad to hear it, let me know if you have any other issues!
     
  48. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    FullSizeRender.jpg Looks like I have one more issue.

    After setting up my character and pressing run, my character move and the mesh is deformed.

    The bat looking thing should be a zombie :).
     
  49. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Are you trying to combine multiple meshes or is it all one mesh?

    Some common things to check for when I've seen people having this issue:

    Ensure the the baseMesh field is set correctly in the MeshAnimator component (should either be the newly combined mesh or the original mesh you baked)

    If you are baking multiple characters with different meshes, but shared animations, ensure that each one is in a different folder. They each need their own baked animation and the animations will override each other during baking.

    If neither of these are the issue, feel free to PM or email me the asset and animations and I'll get back to you ASAP with a fix or identify the issue, it's hard to debug without the model in question. A Unity package works best so I can see your exact setup, just the model + animation is enough.
     
  50. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I think I may have baked at one LOD of my model and swapped the model in the mesh animator after the bake.

    When I rebaked it with the correct model...it now works....thanks for the swift response.


    One last question. When I bake my model...it starts off in a different location than where I place it in the scene. I'v placed it in an empty gameobject to correct it. But since you asset deals with getting large amount of animated charcters (so a lot of empty gameobjects) I'd rather avoid that if possible.

    Any way to avoid that?