Search Unity

We removed all our Animators and gained 30 FPS - [Alternatives to Mechanim]

Discussion in 'General Discussion' started by st33d, Jul 12, 2018.

  1. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739

    I've since done all this. But the Animation clip remains "unattached" to the object. And I can't "play" it in the timeline. The play and record buttons are greyed out, no matter how I select the Animation clip. It's as if it's frozen
     
  2. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    "Have you tried turning it off and on again?"

    just did that... this worked.

    FARK!!!
     
    AcidArrow likes this.
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,563
    What the hell.

    So apparently I'm no longer supposed to use Animator.CrossFade when I don't need state machines?

    Sigh. They could've said this earlier.
     
    landon912 and Deeeds like this.
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    Yeah, like...

    5...

    years...

    earlier...

    ...
     
    Last edited: Jul 13, 2018
    NotaNaN, akasabutski and Deeeds like this.
  5. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    We are in the same boat, but its too late for us to bring back Animation. Maybe I’ll use this as an example for why browsing the forums on work time benefits the company. ;)
     
    NotaNaN, CodeRonnie and AcidArrow like this.
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    Really small update. QA told me this:
     
    DominoM, angrypenguin and r618 like this.
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This is smart. Do not call it legacy but SimpleAnimator, and rename the github version to something like CustomAnimator.

    Animation is a separate concept going forward, from the component for people's understanding, I think.
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    Necro-ing because this thread turns out is still really relevant and nothing really has changed since 2 years ago which is... expected by Unity at this point.

    Animator still is super slow.

    Animation still is called legacy and Unity discourages that people use it everywhere.... except when you complain about performance of animator, at which point is "well if you want performance, use the Animation component".

    I had enough.

    upload_2020-5-12_18-31-20.png

    upload_2020-5-12_18-31-51.png
     
  9. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    The fact that we cant trust the performance of the built in systems are jarring
     
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You can trust the performance of DOTS though, however that's not exactly ready for a lot of developers yet. I mean, when Unity asked these questions years ago, I was shouting loudly that Unity should focus on a clean slate so they can do maximum performance.

    Part of me regrets that encouragement but I don't take it back, it is the right move, even if it's not a move that benefits most people right now.

    Also I am all for optimisations to existing systems if someone at Unity is hired to do this. Just I kind of understand their position even if it can be neglected at times.
     
    Joe-Censored and Rich_A like this.
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    I mean...

    Rebrand Legacy Animation to Animation. Stop discouraging its use (or failing that STOP ENCOURAGING ITS USE ONLY WHEN IT SUITS YOU), hire 1 (one) developer to fix bugs for it.

    I don't understand why the ability to play simple animations in a performant way requires DOTS or whatever.
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm feeling that they'd have spent more time on this and so on if they didn't have to do DOTS as well, is my kind of reasoning behind why Unity hasn't.

    I mean, if Unity's hiring competent programmers, wouldn't they assigned to DOTS to start with? So I dunno if Unity even finds time to work on what should all be considered immutable at this point. I mean, you don't exactly see new non-dots features popping up do you? That's because classic mono Unity is basically frozen at this point.

    Nobody working at Unity told me this, but it's obvious innit?

    Apart from small feature improvements here and there by staff that care, I'm not expecting more features for classic Unity, it feels like maybe one person per area is iterating for us. Unsung champions on Physx, on Particle System and so on, I could keep mentioning but they are all appreciated.

    It's also the right move, I'd have done the same if I was Unity's boss: I'd have existing mono land Unity basically all frozen and in LTS while directing everyone else to work on DOTS and stuff that DOTS needs. Anything else seems illogical and a poor use of resources.



    This pisses people off I'm sure, but it's diminishing returns at this point to focus on mono land. Do I like that? No, I don't. But it doesn't change that it's the right move. It also makes me really grateful when people do find time to work on things like Physics and so on cos I use those daily :)
     
  13. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    I mean surely they are a big enough company they can assign a few developers on maintenance?

    I have to say, that kind of way of progressing fills me with dread. I feel like it's inevitable that once DOTS gets half-working and the tools around it are also kinda-working, Unity will announce they are moving to DASHES which will be the future of Unity, and whose development will take 5 years while development off all current features stops immediately. They are unable to finish a feature. Their messaging is confused. The state of their software is bad.

    But sub money keeps rolling in.
     
    Last edited: May 12, 2020
    Shushustorm and Redtail87 like this.
  14. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,563
    Dots is not really suitable for animation, as far as I know. I mean, you CAN do it, but the point of Animator is to have convenient state machine blend tree setup.
     
  15. FileThirteen

    FileThirteen

    Joined:
    Oct 23, 2012
    Posts:
    40
    Checking in from Unity 2019.4 LTS, here to say the Legacy Animation Component doesn't work at all (from a 2d perspective). You can put the Animation component on a GameObject which has a Sprite Renderer component, and then create an animation for the object in the animation window and the sprites just don't update, nothing updates. I really don't like how Unity deprecates old features before new ones are ready like with UNET. The reason I'm trying to do this is for the same reason as OP, basically many animators slows the game down. I guess writing your own script is the only way?

    And yes I've verified in debug in the inspector that the clip is legacy. I even tried making a non legacy version of the clip and it then gives the console error that the clip needs to be marked as legacy.
     
    akasabutski and ihgyug like this.
  16. ihgyug

    ihgyug

    Joined:
    Aug 5, 2017
    Posts:
    194
    Such a shame that a basic thing like a lightweight animation system for 2D is not a thing (or rather, it's broken and deprecated). With the mentality to cover "all kind of games" in single components, they just force heavy and unnecessary complicated features on many developers. You find yourself doing everything from scratch and not relying much on Unity as it should be.
     
  17. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,332
    @willgoldstone, this is a problem we keep running into that's causing a bunch of headaches. Unity is very back and forth on if the Animation component is supposed to be removed or not.

    We're heading into a 2D project, and we're very unsure about what the right thing to do for animation is. We'll probably either want to use the Animation component or our own hand-rolled sprite swapper, but we don't know if the Animation component will be supported if we find bugs in it. Any chance Unity could actually have a stance on the state of the component?


    For reference; I've done extensive testing, and the Animator component's performance when using an AnimatorController is worse than every other alternative. Playing back a clip using Playables on the same Animator is much faster, but still not as fast as playing the same clip with the Animation component.
     
  18. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,563
    Hand-rolled sprite swapper is likely the way to go.
     
  19. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436

    Did you consider using Godot or Gamemaker instead? Just curious.

    I find all the animation stuff in unity hella cunfusing and would be willing to jump through a couple of hoops to avoid using it. So if I had to animate sprites in Unity I'd probably do my own sprite swapper.
     
  20. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    For 2D, I've either landed on using the Animation or more preferably using my own sprite swapper. Using animator for 2D is often like using a chainsaw to trim my beard.

    Perhaps it's time for an open source tool to be created? Assuming it hasn't been done yet.
     
    Last edited: Jul 2, 2020
  21. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    734
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,366
    Same problem with our game on mobile. Ended up using Animation and went back to a solid 60fps. In our case it was for characters animation.
     
    Shushustorm likes this.
  23. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    614
    What the hell?! :mad:

    Somehow I missed this little change. Yeah damn right they could have said this earlier! I spent literally months "upgrading" BHB: BioHazard Bot to use Mecanim, even though I didn't need any of the new features and despite it missing functionality at the time (I remember even the basic Play(clipName) function was missing at first because they wanted you to do everything with conditions). All because I was told Mecanim was the "way of the future" and Animation was now "legacy" and was going to be phased out like the old particle system, which they did remove, all of which implied that I didn't have a choice and was going to have to upgrade eventually.

    Are you seriously telling me that now Unity has gone back on all that and is saying "Right now you should not be afraid of using the Animation component"? That all that time spent switching to Mecanim was for nothing while also giving worse performance?

    I was frustrated before in this thread but now I'm livid
     
  24. Shushustorm

    Shushustorm

    Joined:
    Jan 6, 2014
    Posts:
    1,084
    This is just as hilarious as the Resources issue. They also strongly discourage its usage. Yet, for many games, both Animation and Resources are very much required unless you want to work on a solution you build yourself, which you also have to maintain for yourself. AssetBundles and the other "alternative" (whatever it's called) aren't alternatives for Resources and just like that, Animator isn't an alternative for Animation. All those things are used in different scenarios. And cutting away from one of them leaves developers without tools they require. I, too, have my own tools for quite a lot of animation, but a simple way to play some keyframes in a performant way is quite important. It's just a basic tool. Why would you throw away a hammer if you buy a jackhammer? You still want a hammer to build a table. It's insane how vital systems that work well and stable aren't supported properly.
    I criticized the behaviour towards Animation very early on when Animator was introduced. I criticized the way Resources is viewed: https://forum.unity.com/threads/ass...t-practice-in-unity-2017.494853/#post-4895006
    Well, at some point you wonder how Unreal is treating its tools.
     
    NotaNaN, ihgyug, Jingle-Fett and 2 others like this.
  25. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    614
    Agreed completely. One of the arguments the documentation makes against Resources is that it says that it can slow application startup by a few seconds (on low end mobile devices from like 2014 when that part of the documentation was written).
    I recently put that to the test by dumping about 3gb of models and textures into resources and the startup time on my laptop was virtually identical to the control version which had nothing in Resources, no noticeable startup delay at all. This was on a 5400rpm HDD too, not a fast one. So even one of the few measurable "dangers" of using Resources ended up being a non-issue, at least for me.
     
    Shushustorm and Martin_H like this.
  26. Shushustorm

    Shushustorm

    Joined:
    Jan 6, 2014
    Posts:
    1,084
    Also, noone seems to mention workflow. Probably because the question of performance is outrageous enough. But Animation was also much less complicated to set up, which resulted both in fewer errors done by the user, which you have to track down as well, as well as immediate time spent to make it run.
    The fact that I need to set up additional files just to make a cube spin already shows the flaws of this workflow. And then, of course, you can't use as many of those cubes, because Animator is needlessly heavy.

    @Jingle-Fett
    Even if Resources slowed down the startup time, depending on your situation, that's very much irrelevant. On console, it's normal to wait a few seconds for application startup. There, the ratio startup time / average play time is very small. Of course, the fact that this flaw doesn't even seem to show up for somewhat current devices is just icing on the cake. There may be a very specific argument for low end mobile, saving those startup seconds, but even then, you have to live with the major drawbacks of AssetBundles as well, which, of course, don't get mentioned. You have to structure your data a lot to not include absurd amounts of useless data in RAM and, here again, the workflow just takes much more time to set up and to use and maintain it down the road.
    Don't get me wrong, Animator and AssetBundles sure have their use cases.
    But for the average scenario I think Animation compared to Animator as well as Resources compared to AssetBundles are far superior. Superior by simplicity, superior by being much less pain to set up, by being much less error prone, by being much faster to work with, saving development time, and, in terms of Animation, additionally being much more performant.
    Enough rant from me. Gotta get things done as well. I just keep as many things engine independent as possible.
     
    Last edited: Jul 6, 2020
  27. heronww

    heronww

    Joined:
    Sep 8, 2019
    Posts:
    30
    Unity is an exhibit of abstraction and simplicity gone too far. Abstraction is good, so long as you have the basics. The gentlemen that said you still need a hammer with a jackhammer nailed it perfectly. Such common sense seems lost at the Unity team.

    Well, there is DOTS right? All experimental unfortunately. I came back after 3 years expecting things might be better. Nothing has changed. I'll be back in 3 more to see if this "DOTS" thing hasn't succumbed to incompetence
     
  28. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    Its not stopped me earning a lot of money through unity via contracting etc. Waiting for an engine to be "perfect" means you will be waiting forever.

    You could use it now and get something done, or you can wait for it to be perfect and get nothing done.
     
  29. heronww

    heronww

    Joined:
    Sep 8, 2019
    Posts:
    30
    You're right. What's the current solution if I want 5000 animated sprites? I'm looking at making a 2D war game like RTS in Unity. I've looked into DOTS but it's not production ready. I'm thinking of experimenting with the script from the OP but just wondering if it's worth delving back into things at this point.

    What is your advise?
     
    MadeFromPolygons likes this.
  30. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    You can totally have 5000 animated 2D sprites in unity, as long as you are following sensible optimisation guidelines etc

    I actually wrote a decent guide on the basics of unity optimization (a sort of checklist for every project): https://forum.unity.com/threads/how-to-optimize-performance-for-large-armies.728729/

    (post #12 in there) - dont necessarily do all of it at once, test each thing individually as some may benefit you, some may actually make it worse or be irrelevant for you!

    The key for animated 2d sprites if you are going for 5000, is to not use the animator component (5000 of those would get heavy quick) but instead go for a "flickerbook" which is basically a script that changes the sprite to the next frame, (animate it yourself basically) that way you have control and can stop things animating that are at a distance too far to see, etc etc

    Either way avoid the animator component for this (or only use on the closest X amount of troops) :) But you can totally start this today in unity!
     
    Last edited: Aug 5, 2021
  31. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    @heronww this looks like a fantastic read too : https://coffeebraingames.wordpress....n-sprites-more-than-120fps-dots-not-required/

    Let us know how you get on! Good luck :)

    TBH you will probably be just fine with 5000 sprites with not much optimization, its the animating them where you have to be clever about it - but its doable and if you need help feel free to ask on the forums in a new thread, as lots of people have experience in getting this type of thing working and lots of ideas to try :)

    The rundown:

    - use https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstancedIndirect.html (Special shader in the article above for helping with this) functions to draw the sprites so you dont need gameobjects
    - use a flickerbook style script to actually animate them
    - use gpu instancing

    just those alone will get you animated 5000 sprites at 60+ fps without much difficulty :)
     
    Last edited: Aug 5, 2021
    heronww likes this.
  32. heronww

    heronww

    Joined:
    Sep 8, 2019
    Posts:
    30
    Alright, thanks. When I'm given a no-nonsense insight like yours, I should pay attention. I now have my work cut out for me.
     
  33. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    Haha yes but it will be fun! Now get out there and make something awesome ;)

    Good luck and welcome back to the community! :D
     
    heronww likes this.
  34. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    Yes, Unity is very good if you want to make money and not games, apparently.
     
    april_4_short and BIGTIMEMASTER like this.
  35. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    Thats not specifically true though is it. I cant help but feel anything you say regarding unity and what it can do/ cannot do is very biased, seeing as you only seem to come here to post very negative comments (at least, it seems like it because thats all I ever see).

    Yes there are plenty of problems with unity (like any engine to be honest though), but lets not blow it out of proportion; many many studios out there are making games with unity without issue - I contact for quite a few. It can and does make games.

    If you have something to actually add to help the user I was speaking to, then feel free. Otherwise you are just derailing this thread with negativity that has added nothing at all to the discussion to help them in their endeavour.
     
    CaseyHofland and angrypenguin like this.
  36. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    lol.

    I think unity can do a lot but you have to stay both within limits of the engine and also limits of yourself too.

    In fact I would say within like 25% of both. In other words, dont go anywhere near the limits of the engine, and stay well within your own limits as a deisgner/programmer/artist, etc. Otherwise taking too much risk.

    The problem is engine is an enigma and "know thyself" is advice nobody wants to hear.
     
  37. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    Thats good advice in any engine to be honest ;)
     
  38. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    I wasn't aware I needed your permission to post on a thread, I'll rectify this in the future.
     
    chingwa and hippocoder like this.
  39. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,976
    You dont, but you do need to follow forum rules about derailing threads :) You also might want to consider that adding a purely negative comment that adds nothing to a discussion where someone is trying to help a user achieve what they need, does absolutely nothing for anyone else in the conversation. What did you gain by adding it here? Nothing except derailing.

    Thats my point. The point was not "ask for permission" and that was made pretty clear in the first post I replied to you with.
     
  40. april_4_short

    april_4_short

    Joined:
    Jul 19, 2021
    Posts:
    489
    Unfortunately, @AcidArrow makes a good point. A sad point, but a good point.

    How many folks using the forum, do you think, are exclusively making their own games (in a team or solo) versus those that primarily do contract work for other teams/producers at an hourly/daily/weekly rate?

    The mindset is very different, and the pressures are enormously different. As are the kinds of advice that come from the different (polar opposites) types of Unity users.

    Someone getting paid hourly, and not truly responsible for the ultimate result, might be interested in claiming that it's possible to analyse and improve the performance of Mecanim for all manner of things, and be willing to experiment on someone else's dollar to try to get it performant and sensibly behaving in pools and when culling etc.

    A "let's get it done and get one step closer to shipping" producer or team member might be much more inclined to just convert everything to Animation Legacy and be done with that, and plan around that limitation, from there on out, and suggest this approach.

    Insight into which type of user is providing information might be super useful for readers.
     
  41. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181

    Bingo. When it's my money and time I am not screwing around. If I have millions maybe it's different story, but I don't have millions.

    So when I hire a person to help and they want to take extra time to find a more clever solution than a simple one that we know works, I tell them not to do that. Would they do it with their own money? No, that is why they are working for others.

    You can justify anything and some times a clever solution is actually worth the effort, but I think for the tiny guys it is almost always gonna be better to simplify a game mechanic if the way to build it isn't already easy and battle tested.

    Same principle as when you fight enemy who is stronger than you. You don't overcommit - you throw strategic jabs and buy time. Have to wait for opportunity to present itself before you make a bigger move. If you do more than that too soon, you'll get got.
     
    Last edited: Aug 5, 2021
    AcidArrow likes this.
  42. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Exactly. Yes, it's possible to develop better animation tooling from scratch in Unity, of course. But that would be insanely expensive to fund when we need to be making games. I know making tools is part of the job - it's actually my favorite thing to do. However, at the end of the day we are trying to ship a game here and are being severely held back by essentially all of Unity's limited and often non-existent toolsets. I have a very special spot in my heart for Unity, but I do not think I will ever make a major project in Unity again.
     
    AcidArrow and april_4_short like this.
  43. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,856
    I do both and have for 12 years. I have used Unity enough to know to work around it when needed. I have had over 20 recruiters in my email in the last month alone. This indicates many studios use it for their projects and earn enough to offer 85K-150K USD for a senior Unity dev. I also am actively expanding development on Cyclotronica, our shoot em up, explosive stunt riding nuclear physics game.
     
    april_4_short likes this.
  44. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,856
    I looked at your Ardenfall site. I can't imagine, given the style and mechanics, why you cannot leverage Unity.
     
  45. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,856
    Yer just swinging wildly here hoping to connect a shot. You do not even program/write code.
     
  46. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    Oh, okay.

    So what do you suggest? Push the engine to it's limits? Bite more than you can chew? Does that net you success in your own game endeavors? Is there more nuance to your reply that a general, "nuh uh, I don't like the things you say."?

    I've found ways to make progress making pretty cool games despite low amount of knowledge writing code. The key is strategy. I do in fact write the code for my current project. But I always have to find ways to continually make progress in the interim time between beginner and expert.
     
    Last edited: Aug 6, 2021
  47. april_4_short

    april_4_short

    Joined:
    Jul 19, 2021
    Posts:
    489
    Bravo.

    Have you noticed similar gains as the OP, when ditching Animators for Animation Legacy?
     
  48. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,856
    Wasn't a big fan of Legacy as at the time I was transitioning from a tech artist with some coding chops from 10 years in Flash to fully understanding the Unity API, but used Mecanim the day it was in alpha release. I preferred it as I was building procedural IK driven martial arts/melee combat and nav systems, could get visual feedback in setting transitions to poses and used the IK system for hands, feet and lookAt. When trying out UE the lack of a retargeting system and the old school architectural axis system were no-goes with me.
     
    april_4_short likes this.
  49. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,856
    Being that I am only competing with myself I will push any system I work with to its limits, understand them and have that work to my benefit. I have 25 years in 3D and 22 years coding backed by 55+ years as a classically trained oil painter, award winning artist and monument sculptor. Give me some limits and I WILL breach them just because.
     
    Last edited: Aug 6, 2021
  50. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    Publishing and selling games is what I was talking about.


    Maybe you are a special case. My strategy is for regular dummies, like me.
     
    Last edited: Aug 6, 2021