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

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi, loving the asset - I've couple of suggestions though.

    1) Requirement: I want to be able to play the same clip again. Right now, method Play is checking to see if it's the same index as current, and returns if so. Can I recommend extending methods Play and PlayRandom with something like following:

    void Play(string anim, bool forcePlay = false)
    void Play(int index, bool forcePlay = false)
    void PlayRandom(bool forcePlay, params string[] anim)

    Or am I doing it wrong, and there is an easier way of doing it? To clarify, I don't want to loop the animation, but repeat on demand.


    2) Maybe adding a readme file with version information (unless I'm missing it somewhere) - without it, it's hard to figure out which version I've on project.

    Thanks again.
     
  2. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    You can use MeshAnimator.SetNormalizedTime(0); this will restart the animation from the beginning.
     
  3. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Doesn't completely solve the problem though.

    So this is what I would like to achieve; I have a character with 3 animation - idle, celebrate and applause. I want randomizer to have a greater weight for idle (ie. 80% chance of playing idle again) and continue playing animation while active.

    Also, I want to be able to play or queue an action on demand; (some event happens within the game environment when I want the crowd to play a certain animation).

    With MeshAnimator.SetNormalizedTime(0), I can solve the first part (though a bit unclean); I can get a random animName, and compare it with the parameter passed with callback - if same, use setNormalizedTime, else use CrossFade to decide which method to call.

    But the next part is partly impossible; I'm not near the source to confirm - but if MeshAnimator has a public property telling me which animation is playing (else I can always store it within my routine), I can check that to know how to Play on demand.

    However, I don't think I will be able to Queue it.

    One hack might be changing the currentPlayingIndex to -1 to ensure it passes the check; but again, it will not work with queue.
     
  4. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I'm not sure I fully understand what you are trying to accomplish exactly, but something along these lines?

    Code (CSharp):
    1. public class RandomAnimationPlayer
    2. {
    3.     public MeshAnimator meshAnimator;
    4.     public string[] possibleAnimations;
    5.  
    6.     private void Awake()
    7.     {
    8.         meshAnimator.OnAnimationFinished += PickNewAnimation;
    9.         PickNewAnimation(string.Empty);
    10.     }
    11.     private void PickNewAnimation(string lastAnimation)
    12.     {
    13.         if (possibleAnimations.Length == 0)
    14.             return;
    15.         string newAnim = possibleAnimations[Random.Range(0, possibleAnimations.Length)];
    16.         // if already playing the new animation, do nothing
    17.         if (lastAnimation == newAnim)
    18.             return;
    19.         // play the new animation
    20.         meshAnimator.Crossfade(newAnim);
    21.     }
    22.     // can be called to force an animation to play from an external script
    23.     public void ForceAnimation(int index, bool queue = false)
    24.     {
    25.         if (possibleAnimations.Length <= index)
    26.             return;
    27.         if (queue)
    28.         {
    29.             meshAnimator.PlayQueued(possibleAnimations[index]);
    30.         }
    31.         else
    32.         {      
    33.             meshAnimator.Play(possibleAnimations[index]);
    34.             // forces the animation to restart if it's already playing
    35.             meshAnimator.SetNormalizedTime(0);
    36.         }
    37.     }
    38. }
    39.  
     
  5. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Thanks for your quick reply; now suppose we have a 250 frame applause animation and currently our animator is at frame 200; now we call force animation with queue as true : from what I recall from your script yesterday, in this scenerio, once animator finishes current animation, it will skip queued animation.

    Ps: neat way of forcing restart on line 35; cool.

    Couple of more things: I'm having the same issue someone else had couple of months ago where the animation would just stop after a while - but in my case, it didn't start after a while on it's own. I'm using animation from crowd asset pack (same as in your demo). I've then marked all the generated animation asset wrap mode from "default" to "loop" and that seems to have fixed the problem.

    GPU Instancing: you mentioned earlier - "So for crowds it's probably a good idea to have a bunch of crowd members animations synced up throughout the crowd, then they'll all be batched into a single draw call!" -- any suggestion on how to sync it?

    I'm getting around 100FPS with 1884 crowd size (model has 3.5K verts, 3.7K tris); GPU instancing working with around 2400 saved by batching; Tris in 9.5M; I'm hoping perhaps syncing would give me a bit more.

    Weird :D added 5 more meshes - so all together 6 meshes, and FPS jumped to 210 without any other changes.
     
    Last edited: Aug 18, 2017
  6. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    For syncing animation, let's say you have 1800 members. Break them up into 200 member increments when calling Play() at a specific time, so they are all playing the same animation on the same frame. Then these 200 members can all be automatically instanced by GPU instancing, allowing you to have only 9 draw calls.
     
  7. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi js, just to clarify, are you saying something along the lines of

    for(var i=0; i < count; i = i+200){ ... play here for }

    aah; I see how manager is controlling the tick - I was worried that the difference in milliseconds while calling the items play would mean all animation would start at different time. silly me;

    Any thought on: "now suppose we have a 250 frame applause animation and currently our animator is at frame 200; now we call force animation with queue as true : from what I recall from your script yesterday, in this scenario, once animator finishes current animation, it will skip queued animation."

    "marked all the generated animation asset wrap mode from "default" to "loop" -- is that the right way of doing it?
     
  8. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It should not skip the the queued animation. As soon as the applause reaches the end of it's loop (frame 250), it should start the queued animation.
    Yes this is correct.
     
  9. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Well, I've managed to setup mesh LOD, and initial testing shows some fps gain. Each character has 3 LOD (all with meshAnimator) and my custom lod switcher; this works nicely as I enable/disable lod gameobject, meshAnimator registers/de-registers from MeshAnimatorManager - beautiful.

    Now to actually control all my animators - it would be messy code if I have to track those myself; It makes a lot more sense using the manager. Right now the list is private within Manager; can we have something like this in manager code..

    public List<MeshAnimator> Animators
    {
    get { return mAnimators; }
    }

    Not static so one has to use the instance to get to it.

    I will be able to test out queue method later. Also I have an idea which might make more character variations possible without the expense. Will send you a PM if that works out.
     
  10. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Additional: in my setup, I have my spawner initiating character prefab, sets playAutomatically to false; after the crowd has been initialized, I am using manager to access the characters and to call Play method over batches. I expected that to work, but nothing plays.

    Reason for it is, MeshAnimator on the character hasn't started yet; and on Start method, if playAutomatically is false, it sets up isPaused = true which then stops the method UpdateTick.

    I think the cleanest way to do it would be to have

    private int currentAnimIndex = -1;

    and on the Start method

    if (playAutomatically) Play(defaultAnimation.name);
    else if(currentAnimIndex == -1) isPaused = true;

    This doesn't break any compatibility, and allows calling play as expected.
     
  11. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    AAARGH; coming from a data analysis background (where accuracy is key and speed be damned), I'm facing so many conundrums in unity that it's uncanny.

    I'm hoping someone experienced with Unity can help me out with the following:

    Suppose we have one model with no LOD, with three instances - one at 10 units, then at 50 units and finally at 100 units away and all with mesh animator (same settings) and GPU instancing.

    So we should have one drawcall;

    Option 2: what is we make a LOD system for that character (tris reduction, lower fps baking or both), so we have three meshes with baked FPS, and with our specified distance, we hit all three meshes.

    Now we should have three drawcalls (as we have three different meshes) - but here, tris count/fps baking is lower.

    Now imagine thousand of characters;

    I understand different project requirements are different - but there are still some common speed techniques; so from your experience, what do you find gets you better fps - lower tris or lower draw calls?
     
  12. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Triangles, in most cases, are easier to render on low-end devices than draw calls. When it comes to Mesh Animator specifically, the more triangles, the more memory is required, so you have to find a balance for what you are trying to achieve.

    If it's a high-end platform with a modern graphics card and CPU, triangles most likely won't be the bottleneck, it will be the draw calls and the CPU usage for animating the objects.

    Best practice, use less triangles and minimize draw calls ;) Lower is always better!
     
  13. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    On your zombie scene, is it your custom zombie or an asset? I'm curious about vert+tris count on it.

    As I need varieties, I'm settings up a system with around 20 unique models (all with three lods of mesh where higher lods are baked with lower fps, higher compression); I've a variable setting up number of leader instance per model; so theoretically with a value of 5 here, I should get 100 leaders (each is a drawcall) where each would drive 10 duplicates to create a crowd of 1000.
    With three lods, in theory, I should get 300 draw calls.

    In practice: so far I've around 8 unique models and 300fps on good quality graphics and gtx 1060. Lod seems to give better fps (exactly like your comment where lower tris is more important than draw calls)

    Haven't figured out why my model with one material is using two drawcall.

    Request: rebaking remembers most settings but not any animation skip rate; so I created an animation with 2 frames skip for idle - next time I want to rebake, it shows 1

    Ps: I read somewhere there is a batch baking feature; silly me, can't find it. Or do I just select multiple objects and use existing menu item?
     
  14. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    The zombie in the video is THIS

    If you use the Frame Debugger it might give you some insight as to why it's 2 draw calls instead of one.
    I'll put out a fix for it not saving the frame skip settings.

    Make sure you have the latest version from the asset store. Then select all the assets you want to bake and at the top of the window there is a batch bake selected button.
     
  15. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Thanks js; one more thing I found; rebaking doesn't remember compression settings either. It's showing me compression from last bake;

    Another request :D I have to change created animations wrap mode to loop to fix the issue where onComplete doesn't get triggered; can animator set wrap mode to existing value (if any) for animations?

    PS: Silly me not seeing that button; so batch is supposed to read existing value or will it be reading current window settings? What happens if it's a model that hasn't been baked before - in that case, does it pick up default values?
     
    Last edited: Aug 22, 2017
  16. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Error with lod group and fast camera:

    I'm getting the following exception:

    IndexOutOfRangeException: Array index is out of range.
    FSG.MeshAnimator.MeshAnimation.DisplayFrame (UnityEngine.MeshFilter meshFilter, Int32 frame, Int32 previousFrame) (at Assets/MeshAnimator/Scripts/MeshAnimation.cs:183)
    FSG.MeshAnimator.MeshAnimator.OnEnable () (at Assets/MeshAnimator/Scripts/MeshAnimator.cs:222)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Not sure why this is happening; but bearing in mind that OnEnable is checking the property resetOnEnable, it makes sense adding the line

    currentFrame = 0;

    just before the line
    currentAnimation.GenerateFrameIfNeeded(baseMesh, currentFrame);
     
    Last edited: Aug 23, 2017
  17. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    So I have one updateDepthTexture DepthPassJob and one draw mesh for each model - thus 2 draw calls.

    Any suggestions what I might doing? camera is set to forward rendering with normal shader for material.
     

    Attached Files:

  18. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It uses the saved settings for each mesh. If it hasn't been baked, it uses either the current window settings, or the settings of the previously baked object in the batch.
    If you do not require a depth pass, you can turn it off on the Main Camera (or whatever camera your using) by setting this to None:

    https://docs.unity3d.com/ScriptReference/Camera-depthTextureMode.html
     
  19. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Can this be used for massive Ai enemies
     
  20. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It does not have AI in the asset itself, but it can be used to RENDER massive AI enemies.
     
  21. JuJuCoder

    JuJuCoder

    Joined:
    Dec 10, 2013
    Posts:
    30
    We are still working with Unity 4, with one of our projects. Do you happen to have unity 4 version of this still available if one purchases the current version?
     
  22. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    If you purchase it PM me the invoice id and I'll put together a version that works with Unity 4
     
  23. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi, got a question about LookAt; I see it working on your demo scene, but in my scene with my models, it all works if I don't set LookAt; my model is the parent object with 3 lod meshanimators inside. If I change lookAt, all crowd items appear flat on the floor.

    I have temporarily got around it by setting LookAt of individual child Item than the parent object (which if ofcourse three times slower for each instance); Any suggesions?
     
  24. Rungsted93

    Rungsted93

    Joined:
    Jun 29, 2016
    Posts:
    38
    Hey is there any way to see all patch notes? I got 1.5.1.3 installed and wanted to see if it would make sense to update :)
     
  25. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hmmm I can't seem to access previous versions patch notes either, but looking through my version control commit logs, it looks like most of the changes are smaller bug fixes, and optimization. Upgrading from 1.5.1.3 shouldn't require any additional work other than replacing the package.
     
  26. Rungsted93

    Rungsted93

    Joined:
    Jun 29, 2016
    Posts:
    38
    Only thing is our recaulculate normals is taking up the most performance in our game 500+ units. Is there some optimization for this? :)

    -Thanks for the fast reply!
     
  27. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Unfortunately, it is a slow process for higher poly meshes. If you don't require lighting on in shaders, you can disable it completely in the scripts. Also check that recalculateCrossfadeNormals on the MeshAnimator objects and recalculateNormalsOnRotation on the MeshAnimation objects is off.
     
  28. ChenySchmeling

    ChenySchmeling

    Joined:
    Jan 24, 2017
    Posts:
    6
    Hello there!

    I'm currently trying to import Events from the animation clip but the Mesh Animator prefab created doesn't come with them. Am im doing anything wrong?

    Following pics of the process:

    1 - Events.png


    2 - GeneratingPrefab.png


    3 - AnimationsCreatedNoEvents.png

    Thanks in advance!
     
  29. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Sorry, but events are not currently imported automatically, you'll have to re-create them. I will look into getting them converted automatically and put out an update if it's possible.
     
  30. ChenySchmeling

    ChenySchmeling

    Joined:
    Jan 24, 2017
    Posts:
    6
    Thanks for the clarification!

    Cheers,
     
  31. ChenySchmeling

    ChenySchmeling

    Joined:
    Jan 24, 2017
    Posts:
    6
    jschieck, i'm not sure why this is happening, basicly when i force the Crossfade sometimes the mesh starts to flicker very quickly and then goes to the next animation



    The code i'm using to force the crossfade is this one:

    Code (CSharp):
    1.                  
    2. if (crossfadingCounter >= tickRate)
    3. {
    4.     crossfadingCounter = 0;
    5.  
    6.     currentAnimation = Random.Range(1, 6);
    7.     if (crossFade)
    8.         this.GetComponent<MeshAnimator>().Crossfade(currentAnimation, 0.3f);
    9. }
    10.  
    And my prefab looks like this:

    Inspector.png

    Am i doing anything wrong?

    Thanks in advance!
     
  32. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi JS, finally had some time to look through the code, and I think I have an idea to reduce memory footprint and reduced initialization time.

    In your zombie project, or in my use case, we had one model that we instantiated many times and allow those to run it's own animation; each instance has MeshAnimator with it's own copy of MeshAnimation, which has it's own dictionary of generatedFrames;

    How about instead have one static/global holder for the generatedFrames with some kind of unique identifier so we know which MeshAnimation it's from; and then when any of the duplicate meshAnimator wants to access that generatedFrames, it's already there.

    Currently I'm generating 1000 crowd size from 15 models, each with 6 animations; so instead of 6x1000 generated frames, we would only need 15x6 generated frames; imagine all the time saved.

    Would you be willing to consider this; and also, I had some previous suggestions...

    >> Reason for it is, MeshAnimator on the character hasn't started yet; and on Start method, if playAutomatically is false, it sets up isPaused = true which then stops the method UpdateTick.

    >> public List<MeshAnimator> Animators

    >> I have to change created animations wrap mode to loop to fix the issue where onComplete doesn't get triggered; can animator set wrap mode to existing value (if any) for animations?
     
  33. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Hi JS, just checking if you have seen my message.
     
  34. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Sorry for taking so long my alerts got disabled somehow. I have not seen that before and I don't see anything wrong with your prefab setup. It's hard for me to say exactly what's wrong just by the video. If possible could you PM or email me the prefab and scripts used to trigger the crossfade and I'll look into it further for you?
     
    Last edited: Sep 14, 2017
  35. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Sorry for taking so long my alerts got disabled somehow. The generatedFrames dictionary is static and exists on the MeshAnimation class, so there is only one instance of it being created for this exact reason to save on memory. The MeshAnimation is a shared object between all instances of MeshAnimators using it, so there can be many instances of MeshAnimators, but there is only ever one MeshAnimation.
     
    Last edited: Sep 20, 2017
  36. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    @jschieck, I feel like such an idiot for not noticing the static field :D stupid me.

    I had to make one more change in MeshAnimator; I renamed current
    private void Start to
    public Initialize()

    and added

    private void Start()
    {
    if (!initialized)
    {
    Initialize();
    }
    }

    reason: to smooth out the loading time, I'm instantiating batches of meshAnimators in each frame. At the same time, I don't want partial crowd to be visible on camera. Instead of changing layers in camera, I've disabled the GameObject that holds all animators. With existing setup, the moment gameObject becomes enabled, it triggers all the Start routines in one go.

    With above change, I can call up Initialize the same time I'm instantiating animator, and not cause the huge spike on enable.
     
  37. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    Hello.
    I recently bought a plug-in, but did not find some items in the documentation.
    My goal is to create an army (~ 5k) with good graphics in a certain place.
    Questions, a subject I had:
    How can I use LOD mesh (different polygon)? I need to have several different GOs, which I will switch myself, or there are built-in / other ways?
    Can I achieve interpolation (smoothness) of the animation with Time.deltaTime = 0.1f?
    Is there a way to merge several objects (with the same mesh / with different mesh)?
    Standard meshBaker does not seem to fit.

    (с) google translate
     
  38. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    How can I use LOD mesh (different polygon)? I need to have several different GOs, which I will switch myself, or there are built-in / other ways?
    Yes it's more efficient to use Unity's LOD system. You can then bake your different meshes and use each one as a different LOD level. https://docs.unity3d.com/Manual/class-LODGroup.html I go into more detail in this post: https://forum.unity.com/threads/mes...nstancing-and-more.284377/page-3#post-2644793

    Can I achieve interpolation (smoothness) of the animation with Time.deltaTime = 0.1f?
    If you are going to slow down time, and still want smooth baked animation, you need to bake at a higher FPS. So if the slowest time will go is 10x slower than 30 FPS, you'd need to bake at 300 FPS (I do not recommend this though) to get perfectly smooth baked animations. The higher the FPS you bake at, the larger the file size and memory allocation will be.

    Is there a way to merge several objects (with the same mesh / with different mesh)?
    When baking, you can merge meshes by adding them using the +MeshFtoilter, and +SkinnedMeshRenderer buttons. To attach different objects, like a sword for example, use the Expose Transforms section then parent them after the bake is done and the prefab is created.
     
  39. Elfinnik159

    Elfinnik159

    Joined:
    Feb 24, 2013
    Posts:
    145
    Thanks for the quick response!

    I meant, can I combine several characters to reduce the number of draw calls (skinMeshCombiner / meshBacker)?
    I can not use "Enable GPU Instancing", because characters do not use standard shaders.
     
  40. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Ahh I see, well it most likely won't work with those plugins. Your best bet would be to implement GPU instancing into your custom shaders, it really doesn't take much work. Examples are on the documentation page: https://docs.unity3d.com/Manual/GPUInstancing.html
     
  41. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    hey,

    does Mesh Animator support AT2 ? in order to reduce memory consumption.
     
  42. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It should support any shaders that Unity supports, so I can't see why it wouldn't work.
     
  43. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    ftejada and blitzvb like this.
  44. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Is this GPU or RAM memory that mesh animator need?
     
  45. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    RAM
     
    blitzvb likes this.
  46. OlliIllustrator

    OlliIllustrator

    Joined:
    Nov 1, 2013
    Posts:
    71
    I just want to throw in a fanboyish: Meshanimator rocks!
    Learning Behavior Trees with Flow/Nodecanvas and today I did an experiment with Meshanimator with a flesh-eating cartoon Plant--- and wow, this is impressive. Unity was choking on 400 plants at 18 FPS, while Meshanimator was able to animate 4000 (!) at average 30 (and I am sure by clever combining with GPU instancing I could even get some more out). That is really awesome.
     

    Attached Files:

    blitzvb, hopeful and jschieck like this.
  47. noahx

    noahx

    Joined:
    Nov 22, 2010
    Posts:
    77
    Hi,
    I did things the other way around, I should have asked first before buying, but anyway. I bought your asset a couple of days ago and I jumped excited to follow the document in the link you provided for documentation and the assets were generated with no errors (mesh animator and mesh animation)... now what do I do with them? where do I attach them? how they connect to each other? Is there a tutorial for the rest of the setup?
    I'm a novice programmer so I should have asked first if this was for 100% coders, cuz I thought this was just to "modify" already configured prefabs and they would just behave in a different and more efficient way (I'm doing all my game with a visual scripting tool).
    Thanks.
     
  48. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    Hey noahx,
    Thanks for your support! So typically when replacing prefabs, your going to replace the transform with the Animator component on it, and it's hierarchy, with the MeshAnimator prefab generated by the tool. It's hard to say exactly without knowing how your prefabs are setup.

    Since you are using a visual scripting tool, it won't have support for playing animations with Mesh Animator, so you're going to probably have to write one. If the tool already has one that already supports the Legacy Animation component, then you can most likely duplicate that as a starting point, as most of the methods remain the same.

    Sorry if my answers are a little vague, it's tough to give specifics without knowing more
     
  49. noahx

    noahx

    Joined:
    Nov 22, 2010
    Posts:
    77
    Thanks jschieck,
    Here's a little more info, hoping to get some directions on how to proceed for my case. Like I mentioned, I'm using a visual scripting tool + "game kit" if we can call it that way, to basically avoid any "coding" (I'm not a coder, even though I can code basic stuff but complex terms get me lost).
    Anyway, the point here is not to dive into that tool because it is not the purpose of your asset to fulfill the needs of all other packages out there. But if you can give me any pointers about where to look at or any idea on how to make it work, would be so appreciated.
    This is just the "prefab" without any other components from the game kit attached. It's just a parent object, and a child object that contains the animations and another child object that contains the other stuff and mesh.



    Creating the MeshAnimator using the prefab and the results, all good:



    If I place the Soldier_AnimatedMesh in the scene and I hit play, both the original prefab and the AnimatedMesh are playing the default "animation", and that's good so far.
    So now the crazy stuff, how can I integrate that to my crazy mix of a project? This is a prefab (same prefab as above) but I configured to work with my game, attaching some components from the visual scripting tool, and one of those is an "animator controller", where Animation is then "child object" that contains the animations and the "Character controller" is basically itself but containing an "NPC controller", which tells the character/object at what speed to move, stay still or wander around, etc. (imaged attached too)

    The NPCcontroller:


    Again, it is not the purpose to dive into that visual scripting game tool I'm using, but to get an idea about how can integrate the animated mesh into this stuff. If I disable the legacy animation controller it doesn't break the game, but it simply can't play the animations, obviously.
    I made a test, configuring the prefab using the Animated Mesh and the prefab moves around as it should but always playing the "default" animation (idle). So the trick needed here is how to tell when the object is moving to play the "walk" animation from the animated mesh (and later the other animations of course at the appropriate time).

    Thanks for your help.
    Noah.
     
    Last edited: Dec 13, 2017
  50. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    It seems you'd just have to make a copy of the LegacyAnimControl, and replace the Animation property with MeshAnimator and then edit the script to work with it (most of the calls like Play() are the same). There's not really any way around that. Or make a simpler controller from scratch and integrate it into the Visual Scripting tool.