Escaping Unity Animator HELL

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ก.ย. 2024

ความคิดเห็น • 1K

  • @deadbroadcastpc
    @deadbroadcastpc 4 ปีที่แล้ว +659

    Not all heroes wear capes...sometimes they just have a super clean animator tab. Thanks for the tip!

    • @MukeshKumar-fo1dn
      @MukeshKumar-fo1dn 3 ปีที่แล้ว +1

      @ZETRO MGL Savage

    • @hawk8566
      @hawk8566 4 หลายเดือนก่อน +1

      They might be wearing a cap though.

    • @whiteingale
      @whiteingale 29 วันที่ผ่านมา

      unity tools are making people worse.

    • @ThePancakeJedi
      @ThePancakeJedi 19 วันที่ผ่านมา

      I'm still using this tip it is excellent imho. But... what if you have two animation layers in the animator?

    • @sephaniya4416
      @sephaniya4416 6 วันที่ผ่านมา +1

      Even this videos thumbnail is this guy wearing a cape... Wdym

  • @VideoGameAnimationStudy
    @VideoGameAnimationStudy 4 ปีที่แล้ว +344

    Dude your videos are a gold mine. I'm trying my best to understand the code as I watch all these different tutorials so I can expand and fix, but you take your time to talk about why things work etc, and it's really helpful!

    • @LostRelicGames
      @LostRelicGames  4 ปีที่แล้ว +16

      Thanks mate, I'm glad to hear the videos have been helpful to you, wishing you all the best.

    • @LostRelicGames
      @LostRelicGames  4 ปีที่แล้ว +18

      Btw, I though your name looked familiar. I'm a big fan of your content. Hit me up on discord if you ever need dev help or want to chat about the craft. :)

    • @joaniepepin4968
      @joaniepepin4968 4 ปีที่แล้ว +2

      As a programmer, I am also a fan of your content, Video Game Animation Study! You taught me a lot and that makes working with the artists on our project easier!

    • @companyomidayendeh5325
      @companyomidayendeh5325 3 ปีที่แล้ว

      @@LostRelicGames sir i have a serious problem in unity for importing Fbx from my work that i created on blender for example i made a Room but in unity back face of room is not shown .my blender is 2.81 and my unity is 2017.3.1. is the problem cause of old version of unity ??what is your advice?

    • @JoeZack
      @JoeZack ปีที่แล้ว

      5_😢 I 😮

  • @Nintendosaiyan3
    @Nintendosaiyan3 4 ปีที่แล้ว +229

    I don't think I've posted a comment in nearly a decade but I had to for this. My main character has 114 animations (thank heck he's nearly finished) and HAD over 2500 transitions between them all (and I was originally planning to add more conditions to each transition to iron out any hidden glitches). It took me a few hours to adapt your solution to my extreme example of animator hell, but it actually WORKED. Now I won't have to worry about all those transitions/conditions/glitches in the main character and all future characters I make! You've probably saved me literal weeks of work once it all adds up. I can't thank you enough. Time to finally relax with some Super Metroid

    • @iDerp69
      @iDerp69 3 ปีที่แล้ว +6

      Super Metroid - Ahh, I see you are also a man of culture. Tried the Varia randomizer yet?

    • @Daniel_WR_Hart
      @Daniel_WR_Hart ปีที่แล้ว +2

      @@iDerp69 I'm watching this vid to make a Super Metroid themed demo.
      +1 Varia randomizer

  • @firesickle
    @firesickle 4 วันที่ผ่านมา

    You know its crazy to me how ultra simple and code-focussed this method is that none of the other tutorials ever mention this is a valid approach. Still 4 years later.

  • @elvictor7117
    @elvictor7117 4 ปีที่แล้ว +47

    Finally!!!!!! I always wanted a more code oriented youtuber for learning Unity. It is funny how I can find videos saying "Make games without coding" but no videos saying "Unity but only coding". Also, I always preferred co-routines, but with this approach, I may try the animator, and things may become better. Thank you for the video. :)

    • @magnuscritikaleak5045
      @magnuscritikaleak5045 4 ปีที่แล้ว

      @Astrah Cat have you tried buildbox that is where visual scripting in Javascript is done right.

  • @SuperJohnsmith
    @SuperJohnsmith 4 ปีที่แล้ว +47

    For those who are using 3D, I find using State Machines and layers and then create logic in code that blends between layers for more complicated animation systems.
    Pro-tip you can use an empty state on a higher up layer as a means to turn that layer on and off as well. For example a layer dedicated to climbing and an empty state within it for when you're not climbing, this way you can use the transition to blend from your base layer to the climbing animations without having to do it through code.

  • @MoonJellyGames
    @MoonJellyGames 2 ปีที่แล้ว +8

    This video is invaluable. I struggled with "Mechanim" throughout my development of Cataclysm, and the complications it caused (due to me using it incorrectly) had a real influence on whether or not I'd go forward with some experimental idea related to animation. It often just wasn't work the risk of messing up the precarious mess that I had.
    Right towards the end of development, when I was making some simple animations for the tutorial pages, I decided to just roll my own animation script using coroutines. It has its own limitations, and possibly problems that I have yet to encounter, but it works and (more importantly) I understand it.
    If I had your video a few years ago, I could have saved myself the trouble. I sincerely hope that no other noob developer has to deal with the Mechanim cobweb with this video as a guide.

  • @zBones762
    @zBones762 3 ปีที่แล้ว +1

    That's the way I did my first controller in Unity. I think that's the best way to design your own system for sure. Straight forward, clean, and easy to work with.

  • @LuizMoratelli
    @LuizMoratelli 4 ปีที่แล้ว +9

    I really like the idea of introducing finite state machines to help control actions/states exclusively, it gets better in the long run than the tangle of ifs.

  • @langlearnkorean8774
    @langlearnkorean8774 4 ปีที่แล้ว +181

    Like another commenter mentioned you are quickly getting into an if/else nightmare. I would highly suggest people watch UnityLearn's - Finite State Machines by Marc Gilbert which specifically uses a similar animation example starting with your approach before changing into a Finite State Machine. Obviously in your example things are still a manageable but with a few more mechanics it could quickly get to become a nightmare, which I've personally experienced before.

    • @iamcheezeYT
      @iamcheezeYT 4 ปีที่แล้ว +3

      LangLearn Korean pls give link!!!!!!!

    • @sirstroopwafel
      @sirstroopwafel 4 ปีที่แล้ว +4

      @@iamcheezeYT learn.unity. com/project/finite-state-machines

    • @harshmudhar96
      @harshmudhar96 4 ปีที่แล้ว +2

      Another thing I like to do is to create Animation Behaviours for similar clips. Then, instead of having one state per clip, I just manage all of the more complicated logic inside the animation behaviour.

    • @EndOfLineTech
      @EndOfLineTech 4 ปีที่แล้ว +13

      This is an intro..... believe it or not.... and you should know this as a “teacher” but you start as simple as you possibly can when teaching..... and for experienced developers who are seeing this and don’t understand this trick yet. Well. They might have the knowledge to know how to clean this up.
      He’s simply showing how to actually do 2d animations. There is no sense in going over other topics and making it complicated

    • @guot7344
      @guot7344 4 ปีที่แล้ว +1

      thanks for the recommendation, upvoted both the video and this comment, very helpful 👍

  • @DennisDenchoDenchyaknow
    @DennisDenchoDenchyaknow 3 ปีที่แล้ว +3

    It took me years to escape Animator hell on my own, THIS VIDEO IS A GOD SEND, I wish it was out years ago.

  • @citizengoose1342
    @citizengoose1342 3 ปีที่แล้ว +6

    I'll just casually and quietly change my entire mentally about animations in unity. Thank you.

  • @dtsprogramming
    @dtsprogramming ปีที่แล้ว +3

    I haven't been in the "Game" long, so my projects never required excessive animations. Now that I'm moving up in the world, this tutorial is a godsend. You spoke directly to my soul when you showed me how to escape Animator OCD and spider webs.
    Thank you for everything that you do. Anxiously awaiting the release of Blood and Mead!

  • @Dani_Krossing
    @Dani_Krossing 2 ปีที่แล้ว +34

    Oh...
    Whyyyyy am I using the Animator for animation states when this method exists...? 😅
    I had the idea of doing it this way a few weeks ago, but thought it might create a bigger mess. Which is also the reason I thought everyone teaches you to use the Animator. But seeing how the setup looks so clean and simple, I can't see why it would not be an improvement over using the Animator.
    Pros:
    - Removing the Animator removes the middle man.
    - You need to talk to the Animator in your code anyways...
    - You feel more in control I could imagine.
    Cons:
    - Can't help but feel there is a reason everyone teaches through using the Animator... Is there a downside I'm not seeing..?
    Either way, I much prefer to do this where I activate the animations directly, rather than my code talking to the Animator, just for it to do a task that could be done a step before. Thank you so much for this. 🙂

    • @LostRelicGames
      @LostRelicGames  2 ปีที่แล้ว +15

      Hey mate, glad this approach has helped. As for the question 'why Is it not taught': one reason is accessibility; to give beginners a more accessible framework-centric approach. The newer input system is another example of this. But while these drag and drop visual approaches might be more accessible for non-coders, those of us who like to build our own management systems can feel their clunkiness. I do think these systems are very powerful for the right users, but for me at least, they cause more trouble.

    • @Dani_Krossing
      @Dani_Krossing 2 ปีที่แล้ว +9

      @@LostRelicGames Thanks a lot for the reply! I figured it might have been related to the learning experience of newer Unity devs. 🙂 Love your videos btw, they give a lot of insight and inspires. 😊

    • @maarten9222
      @maarten9222 2 ปีที่แล้ว

      The downside is that you loose all the benefits the animator provides

    • @juhpeow5318
      @juhpeow5318 2 ปีที่แล้ว

      @@maarten9222 Hello can you tell quickly what kind of benefits you loose from animator? i'm a beginer dev and i don't realy like the animator system... but i don't want to be blocked for my game top down 2D with lot anim for lot charachter thx :)

  • @bluebananalab786
    @bluebananalab786 3 ปีที่แล้ว +6

    For anyone wondering, this works in 3D games too, you just can't use blend trees, meaning the start and end for ALL your animation clips must be the same pose for it to look natural.

    • @christopherromano3210
      @christopherromano3210 2 ปีที่แล้ว

      When you say "you just can't use blend trees," can you be more specific? I aske, because that's where I am right now. I have a 3D, 8-way control blend tree set up, and I'm trying to add extra clips when, say, you hit a trigger or something. But I'm getting stuck in the clip and I'm having difficulty getting back to the blend tree.

    • @bluebananalab786
      @bluebananalab786 2 ปีที่แล้ว

      @@christopherromano3210 It might actually work with Blend Trees. I was having problems getting it to work when there were transitions (connections) in the animator. When you create a new "state" in the Unity Animator tab you will have to choose between ""Empty" or "From New Blend Tree." It works with the "empty" clip when there are no transitions specified, because you can do the method he shows at 4:30, "animator.Play(newState);" ...the question is, does that method work on a Blend Tree? I don't really know. can you Play(BlendTree)?

    • @christopherromano3210
      @christopherromano3210 2 ปีที่แล้ว

      @@bluebananalab786 : I got as far as starting default on the blend tree for 8 way movement, then getting a dance clip to play, then getting back to 8 way movement. Which was great. But after the return to 8 way, I can't get that dance clip (or any other clip) to play a second time. I feel like the Play(blend tree) might put us in a different state since starting the game with the blend tree isn't a play command by default. If that makes sense.

    • @khushmm3990
      @khushmm3990 ปีที่แล้ว +1

      ​@@christopherromano3210ik I'm very very late but in the change animation state function you can use animator.crossfade at the end of it

  • @arsalan.p
    @arsalan.p 4 ปีที่แล้ว +21

    Please please🙏 make a tutorial on 3d Character Movement and Animation. I want to make a 3d game and I am stuck here. 😢
    I have seen many tutorials but I didn't get it.

  • @antoniosaintpierre9547
    @antoniosaintpierre9547 3 ปีที่แล้ว +22

    i feel like maybe i'm missing something since everyone is saying how this is so simple and changed their lives, but when you have dozens of different animation states for your character, won't your method require huge if else chains and wouldn't that be just as complicated and ineficient as using the animator component?

    • @awesome2wsx
      @awesome2wsx 3 ปีที่แล้ว +1

      I am still a novice at programming in unity but I think you can solve that complication by using enums right? To keep it more organized. Having enums for attack or running animations.

    • @dch0rr0r
      @dch0rr0r 3 ปีที่แล้ว +5

      If you have enough animations that that's realistically a concern, you would probably also be considering using a state machine for, say, differentiating between when a character is running, jumping, crouching, and interacting with objects/npcs. If you have a state for jumping, then you only need to check your jumping sprites instead of having a single if/else chain that checks through every possible animation each character needs. That way, if you later add a TakingDamage state or something, you don't need to juggle it within an existing if/else chain, it can have its own, like whether your character is facing left or right and whether or not they're grounded when they take damage.

    • @LucasDenhof
      @LucasDenhof 3 ปีที่แล้ว +3

      The upside is this method is way more scalable. When using the animator normally, you need to have a transition between every animation, because otherwise, you may get stuck on an animation. When using this method, you don't have that problem. Yes, you may need to write some code, but the logic is required whether it is in the animator or in a script, and the structure is far clearer when using a script.

    • @gamedoughhh
      @gamedoughhh 2 ปีที่แล้ว +3

      This method is simple for also a simple game. but for complex interaction game, huge if statements will tangle your head. that's why most of game developers use state machine mecanim.

  • @malindukumaradasa3851
    @malindukumaradasa3851 5 หลายเดือนก่อน +1

    This video is 3 years old but saved my rookie ass today. Thanks a ton!

  • @beng758
    @beng758 2 ปีที่แล้ว +8

    Thanks so much from Germany for this! The only thing I was missing was how to smoothly transition from one animation to another (using animator.CrossFade) in an equally smart way like you determined the delay time for the next animation

  • @WilliamSunPetrus
    @WilliamSunPetrus ปีที่แล้ว

    I havent made games in years but I remember this distinctly being the bane of development for weeks. Thanks for this vid

  • @juanx783
    @juanx783 4 ปีที่แล้ว +3

    Just wanna say a big thank you after watching how to navigate through the animator with so many animations! Great content. One suggestion for those who are still interested in further cleaning the code, you may refer to an enum, or more elegantly, state classes for each state with private fields kept (like previous states, animation length, etc). I first found a detailed description of this pattern in Nystrom's "Game Programming Patterns" and the idea came to me that I could really use this Megaman example to practice it.

  • @hegemon3
    @hegemon3 3 ปีที่แล้ว

    I just spend 5 hours on failing to animate, then followed your advice and done it all from the start in 15 min. THANK YOU.

  • @bahtiyarozdere9303
    @bahtiyarozdere9303 4 ปีที่แล้ว +40

    Managing from code is awesome. Managing with "if else" is impossible.

    • @cptant7610
      @cptant7610 3 ปีที่แล้ว

      What do you suggest?

    • @bahtiyarozdere9303
      @bahtiyarozdere9303 3 ปีที่แล้ว +4

      @@cptant7610 finite state machine. Or simply putting behaviours in separated files, managing states by enableing or disableing them. Or separating the behaviours to the functions, then checking playerstate inside functions for readibility.

    • @TheScorpionAly
      @TheScorpionAly 3 ปีที่แล้ว +2

      @@bahtiyarozdere9303 I agree, all in all, the animator controller is like a Finite state machine in itself, but it's not ideal if it starts looking like a mess...

    • @KuariThunderclaw
      @KuariThunderclaw 3 ปีที่แล้ว +3

      @@cptant7610 Honestly the messy code got me as well so thought about it a little bit.. and honestly it comes down to situation. Like for example, when he showed his massive web it looked like he had some animations based on what the player was wearing (based on the "naked" keyword) and it got me thinking that he could break it down into trees for each outfit type or scenario by using scripts to change the animator controller rather than the animation.
      So for example if the player is naked base, the player starts in the PlayerNaked controller. If they put on an outfit it goes to the PlayerClothed controller
      Basically one of the standard rules of programming. If you can break something into smaller pieces each with distinct roles, you probably should.

    • @Kreesty
      @Kreesty 3 ปีที่แล้ว +1

      @@KuariThunderclaw Or just use layers with Sync. I've done it before and it worked well.

  • @TeriyakiTakeout
    @TeriyakiTakeout 2 ปีที่แล้ว +1

    you've openned up my world man. The one thing that felt like it was limiting me because I hate art UI is now fixed because I can use code. Thank you.

  • @pixboi
    @pixboi 3 ปีที่แล้ว +5

    Nice tips. You can also use Animator.Crossfade() if u want a smoother transition between 3D anims.

    • @ZZaGGrrUzz
      @ZZaGGrrUzz 3 ปีที่แล้ว +1

      THANK YOU!!

  • @subliminalcastillo2126
    @subliminalcastillo2126 4 ปีที่แล้ว +1

    You know you did a good job on a video when someone finishes your video & goes back to the youtube home page, but remember they forgot to like and subscribe, and backed up and did that.

  • @BMoDev
    @BMoDev 4 ปีที่แล้ว +30

    Loved this!
    I think its really important for new developers to realize there are options in how to handle your systems. You don't always have to depend on the pre-built Unity tools.
    Also - Player_piss_small 😏

    • @LostRelicGames
      @LostRelicGames  4 ปีที่แล้ว +8

      Absolutely, game dev is very much about thinking outside the box and carving a path that suites ones own style,. Always good to know the different options before getting neck deep in proprietary systems.
      Also.. legacy animation.... ;) well spotted

    • @xXxDudexAwesomeXx
      @xXxDudexAwesomeXx 4 ปีที่แล้ว

      @@LostRelicGames can this be used in bone based animations as well?

    • @iamcheezeYT
      @iamcheezeYT 4 ปีที่แล้ว +2

      Omg BMo! U were the first channel that helped me become a game dev! Thank you

  • @garlicat878
    @garlicat878 2 ปีที่แล้ว

    Making a 2D game with frame animations for the first time, struggling with the animator state machine. The approach mentioned in the video is basically making a state machine in code while taking the advantage of the animator (so we can create states and assign animation in the editor directly), which makes the animator and code cleaner. Inspiring and informative video! Thank you.

  • @wagnerfernandes4899
    @wagnerfernandes4899 3 ปีที่แล้ว +39

    First I must say that I loved your explanation, it really takes the whole problem of what to do and how to do it for the lines of code only, this is very good. Solves many logic problems, between script and animator.
    But I want to make an addendum, if I may!
    As explained, it is excellent for 2D games, but for 3D games, there is a small problem in the transition from one animation to another, as it passes at once, without interpolation between them. This caused a strange aspect, although it was very functional.
    In research, I found a function that solves this problem, "CrossFade".
    In place of animator.Play, animator.CrossFade ("NameAnimation", time) is used
    This resolves my problem, I hope I helped!

    • @Mp4ctsBlain
      @Mp4ctsBlain 3 ปีที่แล้ว +2

      Thanks, fixed my problem!

    • @adryelgainza1530
      @adryelgainza1530 2 ปีที่แล้ว +1

      By time, is that supposed to be time.deltatime?

    • @MahGhillie
      @MahGhillie 2 ปีที่แล้ว +3

      @@adryelgainza1530 According to the Unity documentation that argument is supposed to be length of the fade, so how long it takes to fade. You can just put a constant there

    • @isakov872
      @isakov872 2 ปีที่แล้ว

      thank you!

    • @wagnerfernandes4899
      @wagnerfernandes4899 2 ปีที่แล้ว

      @@adryelgainza1530 exactly

  • @Renegade556
    @Renegade556 3 ปีที่แล้ว +1

    Thank you! I have 216 basic player animation states. This helped a LOT. It turned from funnel web to neat array!

    • @LostRelicGames
      @LostRelicGames  3 ปีที่แล้ว

      That's awesome man! All the best with the remainder of your project.

  • @NowWeWake
    @NowWeWake 4 ปีที่แล้ว +5

    Thank you for this excellent video. Two things "jump" out at me (hehe):
    1) Definitely check out Animancer. It is a toolkit that very much follows this philosophy not separating the animation logic and the game logic (which mecanim forces you to do). I'm still learning it.
    2) This is an aside, but you're not syncing your inputs between update and fixed update. This will give you heck if you try to implement a double jump for instance. I know that's not the point of this tutorial, but it cost me countless hours as a new Unity developer.

    • @hypedoncoffee2884
      @hypedoncoffee2884 3 ปีที่แล้ว +2

      Can you elaborate on point 2?

    • @twisted_cpp
      @twisted_cpp 2 ปีที่แล้ว

      @@hypedoncoffee2884 Hey, I don't know if you've figured it out by now, but check this youtube video. It explains it nicely and has a tutorial on player jump.
      watch?v=MfIsp28TYAQ

  • @RamonRamirezVideogameDeveloper
    @RamonRamirezVideogameDeveloper 4 ปีที่แล้ว +1

    This just gone to fix a current bugy animation behaviour in my current game's animator setup, thanks a lot!

  • @alvaromorales2334
    @alvaromorales2334 4 ปีที่แล้ว +4

    I don't remember exactly where I read this on the Unity documentation site:
    "You should check/set Animator in LateUpdate that occurs after the internal animation update in each loop."
    Here you are setting the animator state inside Update() method.
    May this cause some problems? for instance, a shake or lag in the animation or something...

  • @Sluppie
    @Sluppie ปีที่แล้ว

    This actually helps me quite a bit. I was having trouble with cases that the animator didn't cleanly cover, so it's nice to know I can actually just do it myself.

  • @DeveloperJake
    @DeveloperJake 3 ปีที่แล้ว +7

    “In my case... fourth eight...”
    Me: See’s all of the “naked” animations that he has
    *Music stops*

  • @NickMivera
    @NickMivera ปีที่แล้ว

    Bro, you literally saved me, I am making a platformer beat 'em up, easily over 40+ animations just for the player. And yes I am a pro at the animation rearrangement game. I will not miss that at all.

  • @NicTheThicc
    @NicTheThicc 2 ปีที่แล้ว +16

    While this approach makes the animator look much more organised, it can still get pretty chaotic inside the script. I guess, this can't really be prevented when there are lots of different animations, however I personally think that using sub-statemachines might be a better approach in the long run.
    I'm still trying to figure out the best solution though.

    • @arjunmehta2853
      @arjunmehta2853 2 ปีที่แล้ว +1

      did you figure something out? rn im using similar to his solution but im worried about future increasing complexity. i have a feeling its a choice between visual hell vs code hell. I'm more used to code hell so i feel safer there.

    • @NicTheThicc
      @NicTheThicc 2 ปีที่แล้ว +1

      @@arjunmehta2853 I'm currently using sub-statemachines to make the animator more clear. For me it works like a charm now, even though it is somewhat chaotic - but much less than before.
      I ran into issues with the workflow using code, because the animations sometimes didn't really transition nicely and it also was quite convoluted. If you're more comfortable using code for stuff like that, it'll probably be the right solution for you, though. However, I do believe that playing around with some different solutions can't hurt. (:

    • @arjunmehta2853
      @arjunmehta2853 2 ปีที่แล้ว

      @@NicTheThicc I tried that. They help a little. Currently I found a okayish solution. So basically I redid my code with only the mechanics first. Then using only the existing created bools of the logic, I synced it with the animator and ran with that. So there is only a small codeblock syncing the booleans between the code and animator. And the actual animation logic is taken care through the animator. It makes my code more readable. And animator hell is slightly better

    • @ohfacts
      @ohfacts ปีที่แล้ว

      @@arjunmehta2853 Incase animations are still getting out of hand, here is what I did which greatly helped. I learnt how to use layers (I am doing 2d spritesheet dev so this might not be helpful). I use layers for different core actions (movement/combat/death/etc). I have my movement layer as my base and others as overrides as when I need them. So, when I need the player to fight, the combat layer overrides the movement layer so only the combat animation displays. Hope this helps!

    • @arjunmehta2853
      @arjunmehta2853 ปีที่แล้ว

      @@ohfacts that may be a smart option, thanks for the input!

  • @EduardoBonfandini
    @EduardoBonfandini 13 วันที่ผ่านมา

    I use this system about 5 years now. Is good to see other people talking about it.

  • @clarctosorion
    @clarctosorion 4 ปีที่แล้ว +25

    So, your solution to solve animation state machine webbing, is to write your own animation state machine?

    • @mysticvalley4566
      @mysticvalley4566 3 ปีที่แล้ว +7

      lol make the threads invisible, what could go wrong?

    • @beri4138
      @beri4138 3 ปีที่แล้ว +2

      @Piponazo And managing animator parameters isn't complexity in code?

    • @mysticvalley4566
      @mysticvalley4566 3 ปีที่แล้ว +4

      That said, it's gonna happen one way or another. We just have to bite the bullet and learn to code. Sharp Accent did this effectively, with booleans and a couple floats to inform anim state switching

    • @muhammadmaulana7874
      @muhammadmaulana7874 3 ปีที่แล้ว +1

      It boils down on how you approach the problem. For me the Mecanim is way too complex for a frame based animation (e.g you only have 4 animations but you need to create a state machine for it) . It is very helpful if you have complex state control scheme or more than 6 or 8 animations clip. But with 40-ish clips with each has its own state? Hell naw...
      The webbing happens since finite state machine explodes exponentially if you add more and more states which in this case more clips.
      It is arguable tho, whether you should create your own state machine, since you could just create a composite state (state machine inside state machine) , for example creating a state called attack which then handles all the attack animation (Unity has support for this btw).
      But nonetheless, i can finally escape the obligatory state machine if i have simple frame to frame animations to handle.

    • @AlexanderSemenovForever
      @AlexanderSemenovForever 3 ปีที่แล้ว +1

      To avoid black box and take over control by learning to code. Seems reasonable.

  • @ParagonJeck
    @ParagonJeck 2 ปีที่แล้ว

    4:40
    OMG, i googled for several days try to find hot to "Not play animation if it already play". And find huge and overhelming or just circumcised metods. And here you are- simple, laconic. Thanx

  • @p199a
    @p199a 4 ปีที่แล้ว +3

    Awesome tutorial!
    I like your approach, instead of trying to use Unity for everything u know that just codding the damn thing is much simpler and will give better results.

    • @LostRelicGames
      @LostRelicGames  4 ปีที่แล้ว +1

      Absolutely mate, because it's demonstrated by official Unity videos does not mean it's the best approach for our own games! :)

    • @DarthMerlin
      @DarthMerlin 4 ปีที่แล้ว

      @@LostRelicGames I've been learning that lesson the hard way for a while now, lol...

  • @MastermindAtWork
    @MastermindAtWork 4 ปีที่แล้ว +1

    I remember this guy named DevDuck had a similar situation to where he just coded the animations. I always was quite confused on how to work with it but this was a good explanation of how does the frame system works

  • @Sarthakz99
    @Sarthakz99 4 ปีที่แล้ว +4

    getting out of the animation hell and entering the if-else nesting hell :( I mean there are layers in the animator, can't that be used to replicate the same thing?

    • @willpetillo1189
      @willpetillo1189 4 ปีที่แล้ว +1

      Yes, and whether that is necessary--as well as the best way to go about it--depends on the specific needs of the project you are working on. And if you code it yourself, you have the control to make those decisions.

    • @LostRelicGames
      @LostRelicGames  4 ปีที่แล้ว +3

      It's less about the layers and more about offloading conditional logic to a proprietary closed system. Developers have been successfully writing games with condition logic for for 30+ years. You cannot write a piece of software without it (animation management being just a small part of a larger game system). Some key advantages of a code approach are; you can Debug.Log your conditions, it's centralized for convenience, and more easily portable to other engines if ever needed.

    • @franciscorv
      @franciscorv 4 ปีที่แล้ว +3

      Actually you can use the state pattern if your update is getting bigger. It's more readable and actually you can decouple the states and make your own "decisions" classes

  • @AJMarraffa
    @AJMarraffa ปีที่แล้ว +1

    This is excellent! I didn't even realize Unity allowed you to handle animations like this. I'm making a retro-styled game, so things don't have to look smoothly blended like more modern-looking games. This is much cleaner and easier to understand than all the confusing GUI elements in the animation editor. It's also easy to genericize one animation controller for multiple characters as long as you name the states in their animator controllers the same thing. Thank you so much!

  • @porky1118
    @porky1118 3 ปีที่แล้ว +3

    I know the problem, that animations override each other, too, even when doing sceleton animations.
    Why is the default a smooth transition? In most cases, that's not what I want, because the next animation starts, where the current animation ends.
    So I basically only want smooth transitions when an animation is stopped in the middle, for example when being attacked.
    And in this case, noone would care, if there is no smooth transition. It might even be a better style because it gets clearer, that the flow has been broken.

  • @venumspyder
    @venumspyder 3 ปีที่แล้ว +1

    BTW I use this SAME technique you describe on my custom 3D game engine on my TH-cam channel. So even with a custom C++ 3D engine, using custom code to control animation will work wonders!

  • @davidmurphy563
    @davidmurphy563 4 ปีที่แล้ว +4

    Ah, I naively thought this was going to be a Godot advert.

  • @milenamazzeo9191
    @milenamazzeo9191 ปีที่แล้ว

    You are a literal HERO! I just finished my first, small Unity 2D game and everything was working perfectly and smoothly except for mothereffing animations! This is exactly what I’ve been looking for, thank you!

  • @edfarage570
    @edfarage570 4 ปีที่แล้ว +4

    So I've been using Unity for almost 6 years now. I make mainly 2D games (usually with frame based animations) and I haven't opened an animation/animator tab in 4 years. I just coded my own animation solution and haven't had issues since
    🤷

    • @r1pfake521
      @r1pfake521 3 ปีที่แล้ว

      Is your own animation solution based on the animator play method or does it use the "legacy" animation system?

    • @edfarage570
      @edfarage570 3 ปีที่แล้ว +1

      @@r1pfake521 man i just change the sprite of the sprite renderers/images using code - its not a complicated system I just drag and drop the sprites into a scriptable object and set the framerate/intervals there

    • @r1pfake521
      @r1pfake521 3 ปีที่แล้ว

      @@edfarage570 Oh I see, that makes sense for sprites, I was thinking about 3d animations and im not sure if there is a easy way to play these without the animatior

  • @originalbinaryhustler3876
    @originalbinaryhustler3876 ปีที่แล้ว +1

    Brother you are the best TH-cam GAME DEV
    BY FAAAR!!! Thankyou ✊🏻❣️👊🏻🤝🏻💪🏻

  • @myavatargotsnowedon9156
    @myavatargotsnowedon9156 4 ปีที่แล้ว +5

    To be honest, all of this would be easier with the Animation component rather than the Animator.

  • @pikXpixelart
    @pikXpixelart 3 ปีที่แล้ว

    Thank god. This video saved me from the anguish of every single project I've worked on in the past.

  • @LostRelicGames
    @LostRelicGames  3 ปีที่แล้ว +14

    Escaping Inspector Panel Hell: th-cam.com/video/b7vY6id63OY/w-d-xo.html

    • @Galaxy_World
      @Galaxy_World 3 ปีที่แล้ว

      lol 10 likes

    • @beri4138
      @beri4138 3 ปีที่แล้ว

      After procrastinating for a month, I removed all transitions and parameters today and changed to using your method of animation. It works great.

    • @beri4138
      @beri4138 3 ปีที่แล้ว

      @Drew Taylor I know almost nothing about 3d but I think you should use an animation controller for 3d games because it supports blend trees.

  • @hunterra217
    @hunterra217 3 ปีที่แล้ว +1

    Sooo much better, I thought I was crazy for preferring to code over using the tools, they always felt more complicated than just making the game do what I want directly, especially with unity 😂😂😂 all tutorials you see try to minimize coding but its honestly my favorite part, its like you said, its so much easier to tell whats wrong when you're using your own code to manage everything instead of buggy anim nets.
    Edit: also, that animator.GetCurrentAnimatorStateInfo bit is genuinely life altering, I really wish I knew about that ages ago, I would have been doing it like this from the start

  • @LostRelicGames
    @LostRelicGames  3 ปีที่แล้ว +30

    Unity Asset I made for easily making platformers: u3d.as/2eYe
    Wishlist my game: store.steampowered.com/app/1081830/Blood_And_Mead/

    • @parijatprasadsarkar1163
      @parijatprasadsarkar1163 3 ปีที่แล้ว

      Finally, a nice way to manage it all efficiently
      But Sir, how to have full control over the animation transitions?
      Like how to make transitions more responsive? Normally, in the animator tab, we can click on the transition and tweak values like "Transition Duration".Is there a way to do the same through code?

  • @elijah-jones-inbox
    @elijah-jones-inbox 4 หลายเดือนก่อน

    I remembered you made this video a long ass time ago. I searched it back up now that I'm making a 2d game. Thanks!

  • @chocobo678
    @chocobo678 3 ปีที่แล้ว +5

    After trying out this approach I don't believe it's a healthy way to deal with animation states. When you have like dozens of animation clips to different contexts, force playing a state through code might create every sort of misbehaviour in the animator specially with animation states overlapping each other. And considering that you'll have multiple scripts accessing your animator after implementing your features, it should be painful to track the origin of an undesired state. In the end you'd be just moving from a messed up animator to a messed up code.
    Code monkey just released an awesome tutorial about handling multiple animation conditions with Blend Trees, which I believe is a way better approach: th-cam.com/video/W2z1BvnT0-o/w-d-xo.html

  • @DonTouch
    @DonTouch ปีที่แล้ว

    From the bottom of my heart thank you!
    i spent about 5 days trying to get multiple gameobjects with their own animator controllers to sync animations based on which direction the character was moving and this is what solved it!
    as soon as i seen that you could use a state to control the animation being played i knew this is what i needed!
    Thank you so much!

  • @danielphil4976
    @danielphil4976 4 ปีที่แล้ว +3

    Idek why I'm watching this, I'm Not even using unity.

  • @SootiestJarl519
    @SootiestJarl519 ปีที่แล้ว

    Dang, this couldnt have come sooner. Actually way too relatable

  • @mo15127
    @mo15127 ปีที่แล้ว +12

    Escape unity animator hell? Just uninstall unity.

  • @Perfectbeing1045
    @Perfectbeing1045 3 ปีที่แล้ว +1

    Your youtube channel is the best unity tutorial channel. You teach us how it works while other people just show some code and tell just to memorize it. Also pls use the dark theme of unity as it is free now.

  • @CaptainGerBear
    @CaptainGerBear 2 ปีที่แล้ว

    I found this video while looking for something completely unrelated, and you have just derailed my entire afternoon by forcing me to redo my sprite animation system. Thanks.

  • @DoubleOSevan
    @DoubleOSevan ปีที่แล้ว

    Simple, yet satisfying. The gates of Animator Hell have closed for good. Cheers 🍻

  • @chrisfarlee6496
    @chrisfarlee6496 3 ปีที่แล้ว

    i almost fucking cried when you typed "play" like why in the fuck didnt i search that up in the documentation. youre a saint thank you sir

  • @daveh5139
    @daveh5139 2 ปีที่แล้ว

    I am seriously redoing my entire game now, all animations THANK YOU!!! this is going to be way better.

  • @shavais33
    @shavais33 2 ปีที่แล้ว

    Super nice! This is sooo much better than trying to use conditions and transitions and all that.
    To recap my current impressions -
    A game object has an Animator component.
    An Animator component has a reference to an AnimationController.
    An AnimationController can be opened, which opens the Animator Window.
    The Animator Window contains a number of Animation States, which are displayed as boxes.
    An AnimationState (other than the default states, like "any state" and "entry") contain a "motion" reference, which can reference an Animation.
    An Animation, when double clicked, opens the Animation window, which has the timeline with events and key frames, and a pane with the list of Component Attributes the animation animates.
    So when you GetComponent(), and tell it to Play(StateName), the name you're referencing is the title of the state box in the Animator Window, I guess? Which you can set in the Inspector when you click on it..
    I think in these videos you mention somewhere..
    - ..how to delete or repoint that default entry transition, so it doesn't cause an animation to play on awake.
    - ..how to stop it from looping; just double clicking the state to get to the Animation, then unchecking the Loop Time checkbox in the Inspector doesn't seem to do the trick.
    Bonus:
    - what are these animation layers and what can/should you do with them?
    - More importantly: What is a good way to synchronize between a streamed audio clip, like a cinematic/trailer audio clip, and one ore more animations? Do you just repeatedly poll the time field of the audio source? Or is there a way to schedule animation events so that Unity triggers them when an audio source reaches a particular time?
    This can be ignored, I'm just writing out my thoughts, here, and trying to help promote the TH-cam channel. This evening or this weekend I hope to sit down and subscribe on Patreon and join the Discord channel, and ask my questions there.
    Double Bonus:
    So if you have a few thousand Patreon supporters, that's a fair sized chunk of change headed your way. Are you afraid that if you release Blood and Mead, your support base will fall off after that? But you can just start a new game project, right? Are you afraid your support base will not be as interested in the new project? QUIT THAT FEAR STUFF! I WANT TO PLAY BLOOD AND MEAD! ;-) "No! I'm just not finished with it yet!" Really. Well, I'm almost 40 years into Zone Assault, lol. And I'm not as far along as you are, so. Color this glass pot black.

  • @dirtywhitellama
    @dirtywhitellama 3 ปีที่แล้ว +1

    It's taken me days to watch through this video but even ten minutes in this has revolutionized my animation code in my project. Fantastic video, thanks a lot!

  • @fireraccoon_
    @fireraccoon_ 11 หลายเดือนก่อน

    Thats the best in the whole world animation setup for small not complicated animation transitions i believe. HUGE thanks for it. I promoted this video in my tutorial this must be shared everywhere. Power of deathmetal!

  • @kabrol22
    @kabrol22 3 ปีที่แล้ว +1

    Could not figure out how to trigger my animation through the trigger parameters.. This made it so much easier. Thanks

  • @mattjclay
    @mattjclay 4 ปีที่แล้ว +2

    I love how I watched this after I wove an 8 direction movement spider web. Amazing thank you.

  • @Austinitic_steel
    @Austinitic_steel 3 ปีที่แล้ว

    Dude thank you so much. The number of other tutorials and even answers online that say just to use blend trees and transitions and access the variables via player states or what have you is actually infuriating.

  • @203maryamsaleem9
    @203maryamsaleem9 ปีที่แล้ว

    Watched a lot of tutorials but this is what I was really wanted to know.

  • @mannig.faltigkeit2341
    @mannig.faltigkeit2341 ปีที่แล้ว

    Thanks a lot for that. I was quite unhappy with the net I created. And I know it is still going to grow.

  • @wazaDev
    @wazaDev 3 ปีที่แล้ว

    Some times I can think TH-cam can read my mind cause this is exactly what I needed this tutorial as gold and might save me headaches

  • @davincentcode3662
    @davincentcode3662 3 ปีที่แล้ว

    Dude, this helps me so much, just got into programming and coding, trying to learn how to make my own games. I followed a tutorial which actually made such a mess of the animator system that I lost sight of an error within the animator system, taking me hours to find out what that error was. Thanks man!

  • @Richard-zs1bm
    @Richard-zs1bm 2 ปีที่แล้ว

    Mate, great video. As a full time software engineer just getting into unity and c#, it’s these kind of tips that I’m looking for, and intro courses only tend to give the basics. Keep em coming!

  • @luisrosado7050
    @luisrosado7050 2 ปีที่แล้ว

    I still cant believe i missed the part about the "play" function whilst reading the manual! Well to be fair you dont know what you dont know but still! I wasted SOO much time not knowing this could have been SOOOO much easier! Thanks for the tip!

  • @satoshisaito842
    @satoshisaito842 3 ปีที่แล้ว +1

    Wow this is purely amazing I had a lot of headaches with unity animator but it simplifies everything thank you

  • @baddogstudios.4467
    @baddogstudios.4467 2 ปีที่แล้ว +1

    This was a godly tutorial! I was literally working on my animations today and trying to find a way around the absurd mess of a controller. This tutorial tho. This tutorial! 🙏🏼🙏🏼🙏🏼🔥🔥🔥

  • @firesickle
    @firesickle 4 วันที่ผ่านมา

    I hope this video has what I am looking for cause that openning moment is exactly why I am here.

    • @firesickle
      @firesickle 4 วันที่ผ่านมา

      3:05 YES THIS IS WHAT I WANT THANK YOU

  • @inferbee2572
    @inferbee2572 2 ปีที่แล้ว +1

    Thanks for this heads-up for saving hours on not using the linking transitions method as before :)

  • @Lua_computa
    @Lua_computa 2 หลายเดือนก่อน

    Wish I knew this sooner, haha! Thanks for the video! My upcoming project is planning to have a lot more expressive and dynamic animations than my previous one so this video is basically perfect.

  • @kotcstudios
    @kotcstudios ปีที่แล้ว

    Uggh, days of going back and forth between blend trees and rolling my own animation manager than I found your video. It hit every single point I was having issues with!
    Thank you!

  • @AzeliaIsill
    @AzeliaIsill ปีที่แล้ว

    I nearly broke my Screen with how irritating it got trying to sort it out, you saved my monitor and me
    And earned a sub

  • @garimasharma2384
    @garimasharma2384 3 ปีที่แล้ว

    I am really like him, fully code oriented and wanted someone to do such a video. He is literally a life saver(my animator tab looked the way he showed at the start)

  • @simoncodrington
    @simoncodrington 4 ปีที่แล้ว +1

    Great little video mate. Always good to see how other devs are handling unitys spiderweb of an animation system.

  • @GD-Monkey
    @GD-Monkey 2 หลายเดือนก่อน +1

    This is working, what is awesome after watching too many bad tutorials :) Thank you very very much :D

  • @brian3279
    @brian3279 ปีที่แล้ว

    this is by far the most important game dev video I have watched

  • @mrxpcookie
    @mrxpcookie 4 ปีที่แล้ว

    I love you, I have been thinking that there has to be an easier way of using animations other than just a wall of bools and you have truly made my unity experience so much better in 3 minutes, I am in tears thank you.

  • @TheClanFollows
    @TheClanFollows ปีที่แล้ว

    I barely know unity (just learned animations and transitions how you said is wrong 20 minutes ago in an online class) and I completely understood how this works. Great tutorial, and perfect timing for me :)

  • @CypresssChill
    @CypresssChill 3 ปีที่แล้ว

    Thank you so much! I haven't done Animation's ever before. As an experienced programmer, when I discovered the animator, I instantly saw what was coming. So I looked for an alternative. Gladly I found your video, so I don't actually need any alternative.

  • @plexus1825
    @plexus1825 3 ปีที่แล้ว

    Thanks for making this video because I was about to give up on animating my games for the reason explained in the video. Now I can animate without wasting a bunch of time.

  • @Deviate_Dv8
    @Deviate_Dv8 2 ปีที่แล้ว

    Man, I had really hope this would solve my issues but besides having unique problems in my own project (animation playing too fast, Grounded never being true), I have already found three bugs in the Mega Man one you provided:
    1. Press Space at any time in the air and you will jump as soon as you hit the ground, showing the idle animation. Doing this while walking, shows the walking animation in the air.
    2. Pressing attack during walking still moves you.
    3. Pressing attack right before you land, keeps you in the "attack in the air" animation for few seconds.
    Maybe I should start a career in QA because no one else seems to mention these things...

  • @washburnlane
    @washburnlane 3 ปีที่แล้ว

    Wow! I just did this on my little sandbox game and it worked. Thanks so much, this is a fantastic approach to animations, I wish you great success on Blood & Mead.

  • @ZaCkOX900
    @ZaCkOX900 4 ปีที่แล้ว +1

    So glad I am not the only programmer who animates like this.

  • @nikson12gg
    @nikson12gg 9 หลายเดือนก่อน

    You gave me so good idea ❤
    It fixed my animations' bug, made my animator very easy to understand and it also took less lines of scripting

  • @user-qh9xl9ry7d
    @user-qh9xl9ry7d ปีที่แล้ว

    I didn't know that effective solution for 2d frame animation. I will use this way right now. thanks!

  • @mediabass
    @mediabass 2 ปีที่แล้ว

    Creating animations is the next subject I'll have to learn in unity. As a senior software developer I'm exited to begin with it using this method straight away 👍

  • @joofville
    @joofville ปีที่แล้ว

    I’ve been tangled in a web of animation states. Thanks for this mate I’m going to implement this. You rock