Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    4,873
    have you run into this... and fixed it?
    Seems to happen when switching to another scene
    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <9577ac7a62ef43179789031239ba8798>:0)
    4. System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <9577ac7a62ef43179789031239ba8798>:0)
    5. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <9577ac7a62ef43179789031239ba8798>:0)
    6. FSG.MeshAnimator.Snapshot.SnapshotMeshAnimator.ReturnCrossfadeToPool (System.Boolean destroying) (at Assets/Scripts/MeshAnimator/Scripts/Snapshot/SnapshotMeshAnimator.cs:348)
    7. FSG.MeshAnimator.MeshAnimatorBase.OnDestroy () (at Assets/Scripts/MeshAnimator/Scripts/Common/Core/MeshAnimatorBase.cs:183)
    8. FSG.MeshAnimator.Snapshot.SnapshotMeshAnimator.OnDestroy () (at Assets/Scripts/MeshAnimator/Scripts/Snapshot/SnapshotMeshAnimator.cs:269)
    9.  
     
    chadfranklin47 likes this.
  2. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    105
    Just thought I'd reply as we're on our own for now. I'm using 2020.2.2 [need to update to LTS] and I've check for this changing scene error and I am not able to duplicate when switching back and forth between my Title scene and Game scene.
    In my game scene I spawn around 1200 mesh animator characters which were baked from snapshot mode, but I do not use Crossfade. I just couldn't get it to work so I baked some transition animation clips instead. I see you're error log mentions ReturnCrossFadeToPool. Would it be possible to disable crossFade in your code and see if the error still persists?
     
  3. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    133
    I haven't run into it yet as I am not doing any scene switching at the moment. I will be soon, so I'll be on the lookout for it and let you know if I manage to fix anything though.
     
  4. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    4,873
    Thanks for the hint. I looked at crossfade code: it uses a job to generate intermediate mesh, which then gets cached to avoid hitting the cpu a second time. It's rather clever but clearly broken and since I couldn't trace why that exception happened I commented out the crossfade. Now it runs without exceptions and I cannot tell the difference as it fits the cartoony style of animation.

    I don't know so I use caution out of experience: when my own pooling misbehaved in a similar way it was due to a flaw in logic and that caused all sorts of weird bugs, plus memory usage kept expanding.
     
  5. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    133
    Yeah, I wouldn't look past it. When you say you commented out the crossfade, you mean you're just not using crossfading at all anymore?
     
  6. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    4,873
    Correct, Play() all the way.
     
    Klausology and chadfranklin47 like this.
  7. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    105
    For clarification we are having issues with crossfade of snapshot mode. If I had to guess crossfade of shader mode is less troublesome... which should be based on creation of an image versus creation of meshes.

    Also it is important to note that in snapshot mode I'm getting very consistent callbacks of OnAnimationFinished(). So I was able to create my own 'crossfade' animations and use this method to play the next animation. However, creating the transition animations can be very tedious.

    Someday I plan to switch to shader mode, maybe next project, but only with a supported code base. This is an interesting asset where the plugin is much needed but the developer has gone AWOL. If he doesn't show up any time soon I would gladly pay someone to maintain the code. Just saying.
     
  8. avebury10

    avebury10

    Joined:
    Apr 16, 2020
    Posts:
    2
    I'm running into some basic issues so went back to the provided assets to see if I could even get the process working with them. Going through the SnapShot process with the provided HumanCrowd prefab and CrowdCrontroller the AnimatedMesh is created and the crowd snapshot anims but when running the scene the character is stuck in default pose with no animation running. The following error is kicked up over and over during the process:

    DivideByZeroException: Attempted to divide by zero.
    FSG.MeshAnimator.Snapshot.DeltaCompressedFrameData.op_Implicit (FSG.MeshAnimator.Snapshot.DeltaCompressedFrameData s) (at Assets/MeshAnimator/Scripts/Snapshot/SnapshotMeshFrameData.cs:82)
    FSG.MeshAnimator.Snapshot.SnapshotMeshAnimation.get_frameData () (at Assets/MeshAnimator/Scripts/Snapshot/SnapshotMeshAnimation.cs:35)
    FSG.MeshAnimator.Snapshot.SnapshotMeshAnimation.OnEnable () (at Assets/MeshAnimator/Scripts/Snapshot/SnapshotMeshAnimation.cs:55)
    UnityEditor.AssetDatabase:CreateAsset(Object, String)
    FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/MeshAnimator/Editor/MeshAnimationCreator.cs:1798)
    FSG.MeshAnimator.MeshAnimationCreator:CreateSnapshots() (at Assets/MeshAnimator/Editor/MeshAnimationCreator.cs:1478)
    FSG.MeshAnimator.MeshAnimationCreator:OnGUI() (at Assets/MeshAnimator/Editor/MeshAnimationCreator.cs:912)

    And also the following once:
    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
    FSG.MeshAnimator.Snapshot.SnapshotMeshAnimator.OnDestroy () (at Assets/MeshAnimator/Scripts/Snapshot/SnapshotMeshAnimator.cs:280)

    Unity version is 2020.2.7f1
     
  9. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    133
    With the shader mode, there seems to be some problem with shadows I can't put my finger on. It's weird because it doesn't happen all the time. Maybe just an issue with the outdated shaders:



    Edit: Tried updating the shaders myself and the shadow problem persists.
     
    Last edited: Apr 10, 2021
  10. Jmonroe

    Jmonroe

    Joined:
    Jul 7, 2012
    Posts:
    105
    Since I'm paranoid about the asset breaking I downloaded Unity2020LTS today [2020.3.3f1], created a blank project using 'Built In', switched to Android, and imported Mesh Animator and tested the MAExample_Crowd scene. Although there are script warnings and a camera GUI layer error that resolved itself I had no problem playing the scene as is. Then I proceeded to bake the HumanCrowd animations using snapshot mode to a different folder... again no issue. Then I had the spawner script spawn this new prefab in the demo and it worked as expected. I am pleased with these results.

    The details above are my settings for using MeshAnimator and they seem to work fine [for now]. Any other settings / platforms / rendering methods may have different results. Good luck!

    crowdExample.PNG bakedSuccess.PNG gui layer.PNG
     
    hopeful likes this.
  11. avebury10

    avebury10

    Joined:
    Apr 16, 2020
    Posts:
    2
    Thanks. I tried it in a brand new project with the MeshAnimator assets and it worked fine with your settings which is reassuring. I'll go back and try and track down why it isn't working in the main project.
     
    Jmonroe likes this.
  12. Coco07

    Coco07

    Joined:
    Mar 7, 2017
    Posts:
    16
    Hi jschieck,

    I have 2 questions about the MeshAnimator: 1. Is there a way to lower the texture resolution in the Quality Settings without newly spawned MeshAnimator objects becoming invisible?

    2. As soon as I create a MeshAnimator, a unit appears in the overdraw scene which is at least 30 times as large as the original MeshAnimator object. This large object is only visible in this overdraw view and I was wondering if they are affecting performance in any way?
    Bildschirmfoto 2021-04-13 um 02.27.29.png

    Thank you in advice! :)

    Best,
    Coco 07
     
  13. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    4,873
    a word of caution: if you load a scene and activate it, snapshot incurs a massive penalty
    upload_2021-4-18_19-54-45.png
    140 ms for 1 creature, again, that's not on instantiation of creature, that's on scene load.
     
    chadfranklin47 likes this.
  14. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    96
    Any idea what causes such a huge spike for OnEnable? I have not used snapshot mode but was intending on trying it out.
     
    chadfranklin47 likes this.
  15. parsec72

    parsec72

    Joined:
    Feb 27, 2020
    Posts:
    1

    @jschieck



    Hi , any chance you can provide an stadium spawner with a configurable de curvature and gaps?
    also any video tutorials besides the overview ones? an steep by steep to replicate the stadium scene would be great...
     
    Last edited: Apr 19, 2021 at 11:03 PM
  16. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    4,873
    It shouldn't happen until the object is instantiated and the scene is active so I chalk it to bug bug bug. Time to feed the player with fade to black.
     
    Klausology likes this.
unityunity