I'm comforted knowing I'm not the only one driven crazy by this. I also spend way more time in Shader Graph lining up nodes than I do making actual shaders...
I love how this video is under 2 minutes. Quick and straight to the point. Personally, I prefer the tree and have spent a great amount of time mastering it, but for quick prototypes and game jams this would be WAY faster to set up compared to messing with the tree.
What do you prefer about the graph/tree? I've only made a couple small projects in Unity, but this approach seems much more convenient to me. Would it be a problem with scale?
@@Glooberloob The strength of the graph/tree I believe would be helpful for 3D games such as combo-ing and whatnot. Also, the Finite State Machine Behavior can be more easily used in conjunction with the graph/tree (I think, correct me if I'm wrong but I find it easier to fix there especially with AI)
I switched to code-driven animation almost from day 1 of learning Unity after seeing LRG's tutorial on how to avoid Mekanim spiderweb madness. I barely even know how to use the Unity animator at this point. Your string hash to int trick is something I have not been doing though, until now! Thanks!
@@gamedevteacher7065 ua-cam.com/video/nBkiSJ5z-hE/v-deo.html&ab_channel=LostRelicGames Simple little string based animator state machine. I've extended it a bit for personal use and even implemented parts of yours, but John's does a fine job even just out-of-the-box
Have been programming in Unity for over 6 years and always wrote my own animation system to avoid the issues addressed in this video. I never heard of CrossFade, this would have solved everything I solved writing my own systems while keeping it connected to the tools Unity Provided. Thank you for showing this! To return the favor, let me address the following thing I noticed about the video: About the animation states. I categorize finite state machines into 3 categories: Level 1: Tracking state by multiple booleans Level 2: Tracking state by an enum Level 3: Tracking state / having the logics of states in separate classes. You were using a Level 1 Finite State Machine. I highly recommend going for a Level 2 or Level 3 Finite State Machine. The nice thing about having it in separate classes is that you can do simple things such as: * WalkingStateClass (holds logics of walking) * FreezeStateClass (changes color when entered, and back when exited) And to have the player freeze when hit by an object, you only have to: CurrentState.Exit(); CurrentState = new FreezeStateClass(); CurrentState.Enter(); Because WalkingStateClass is no longer CurrentState, it no longer is being updated so no walking logics is available anymore. Keeping your behaviour simple and preventing complicated bugs.
Im getting into unity with some friends. Im a professional programmer but this is my first real foray into game dev. My friends are all artists so I handle all the code. This channel is everything I want. I can figure out how to do nearly everything from the docs but never really know if Im following good practice. Most tutorials have been worthless because theyre not written for or by programmers. Loving you channel because its exactly what Ive been looking for
Yes - an explanation of your full code, and what connects to what components, what terms or commands actually do, why you use the techniques and code you use, etc - that'd be very useful to us folk just starting out!
I highly recommend using Playables graphs for 3d animation. It's built into unity (but with little documentation) and offers even more programmer centric design. For instance, you can use animation clips as serialized fields and reuse animation graphs just like you reuse code. There is extra work needed to get it set up but it gives you so much more control. It also let's you customize transitions so they're not linear!
had to come back with a new channel because the game i was working on last year uses your character controller... thank you for existing btw! hope you're overcoming any stress you're dealing with at this current point in time and that this year goes great for you :)
So much information condensed into a video that's under 2 minutes. Beautiful Taro! And now it feel like a ton of my videos should be refactored to use this method of animating XD
LockState is probably what I needed. I followed LostRelics version of this in a lil endless runner I made and I noticed animations being overridden. So in the animator I linked necessary ones back to idle, also turning off the autoloop, and then in my if statement checking player states, I stop/prevent the state changing unless it's not one of those animation states. E.g. player is landing from a jump, even if they are grounded, I don't want idle to play since I want the jump animation to finish, if not jumping play idle but when jump is finished in the animator it will go back to idle. Your LockState example essentially does what I wanted 👌 Also I wish beginners knew of this because Unitys spider web is a nightmare and I can't see an advantage over just coding it.
Probably outside of the scope of a quick vid like this, but if you're using a state machine pattern within your own code, changing animations like this can easily be handled more elegantly than a block of if statements, ESPECIALLY if your animation is tied to state. Just have some sort of "onStateEnter" function on your states where you set your animation.
Good stuff! My current game is a track- based music game so all of my character animating is being done on the timeline for this one, but I'll definitely keep this in my bag of tricks for future projects. The more you can calculate programatically, the better!
@@Tarodev Actually, that makes sense. I was just going to make manually animated segments with timeline triggers to branch/loop, but that could potentially help automate at least some of the animation setup. I'll have to weigh my options!
Damn. I wrote my own animation script because I found the cumbersome web of nonsense in the Unity animator not worth the effort for 2D stuff. This seems like it cuts down on that problem though and still allows making the animations in the animation editor. Excellent stuff!
@@Tarodev yeah I tracked time elapsed in the update function and then changed the sprite to the next one in the array when it reaches the duration of a frame. It's pretty basic but it works for the project I'm using it on right now. If I need something more complex though like for a platformer character I will refer back to this video.
Amazing idea. Animated transitions have not been relevant for some of my games over the past few years. I just created a state machine for the MonoBehaviour and just played and adjusted the animation state in the logic state like you showed in the video. It avoids many of the problems of dealing with animators and having to maintain two different state machines.
Holy shit, is this video really only 2 minutes long? It felt much longer, and I mean that in a good way. A lot of information presented very concisely and intelligently. Thank you.
Hey TaroDev! Great video, honestly struggled with animations and the damn spider webs way too much. Actually checked you out after the blackthornprod 3d game dev video, you were a complete machine in that! Thanks for the video mate, have a good one!
This is the most useful Unity tip I've seen in a while. Mecanim is a very useful tool for 3D characters, but so much annoying overkill in many other situations.
I experimented with crossfade on a small game but I noted that the animation can get stuck sometimes. I searched online and found several discussions on the topic. It appears that crossfading a non looping animation can get stuck and does not exit the animation even if you are crossfading another one next.
As someone who uses script-based animation switching (i.e. using it to start an attack or dash animation from idle), you should also keep in mind that you can point the animator to an Animation Tree, allowing you to still use those should you need them. If you have a top-down shooter, for example, you can script the animator to go to an "Attack" animation tree that then uses animator float values for x/y direction to show the correct animation for the chosen direction. This could also work in the example shown here, where you could have two different attack animations depending on whether you're in the air or on the ground,
This is absolutely fantastic, thank you so much! I love doing things through scripting, it just makes so much more sense in my head, and I feel like I have so much more control over how I do things. Never going back to spaghetti trees lol.
Taro, you handsome devil! I was about to do a video very similar to yours this friday! I'll still do it, though, because it's about 4-directional movement with only coding, but, damn! Talk about collective unconscious!
For a small game, those if-branching would be fine. When you go into larger games and optimization (probably what bigger studios would want from a programmer), you will need to start learning code patterns. State machine is the most common (I think?) for changing anim states.
Yup, FSM. But try not look at the 'ifs' and immediately think 'not maintainable'. It may seem like that... but you'd be surprised. 10 conditions in a row would achieve the same as 10 files, each with 10 lines each in a FSM. Want to add a new state? just slot it in where you think it takes priority and you're done. I do agree a bunch of if statements looks like bad code, but this really is lovely to work with. Try it out ;)
Anything I want? - The video on Quaternions ;P. (Take your time) - Also you replacing Brackeys on YT. - ACTUAL IDEA: I would like a revisit of your Ultimate 2D Platformer Controller in Unity, but 3D 3rd Person. - Lastly, I want you to be happy and loving what you do. Same for all fellow devs!
I used Crossfade in a project where I had a problem - the animation wouldn't go through... :( I was using the finite state machine pattern, and althought the state did change, the animation did not. It only happened on that one project & I haven't found a solution for this. I have however, came up with an interesting, Any State Transition workaround (also like a programmer. Aint no body got time to hand make this): 1) get all animator states names into an array 2) create a trigger parameter for each state (paramater name is the state name). 3) save these states into a string array 3) create transitions from AnyState (green state) to each state with the corresponding trigger parameter 4) create a function to trigger state by id (reset trigger immediately after if needed) 5) profit
Another great video! Can we have your take on creating an inventory system? I know this has been done many times before but I love how simple you make complex topics and I'm sure you'll do a fantastic job with inventory. Covering things such as; Setting up the inventory, drag and drop functions on it, reactive UI based on what you have picked up / dropped and maybe some extras such as combining items from that inventory (for example, crafting.) Because these things are used in many games.
"Taro, there's this thing that's be making me crazy for the last six weeks." ~Hmm let me see. Yeah, what you're dealing with IS difficult. At the moment, it's just not that intuitive and it's not your fault if you're having problems. Here, start with *THIS*.~ "Oh dear lord! That's awesome. It's elegant. It's scalable. It.. It.. Just give me a moment." ~Have I done something wrong?~ "No, you just don't understand how it feels when you're playing by the rules and it STILL doesn't work OR when you can't even find the ******** rules at all. Well, I guess you do. I guess that's why you've been making great resources for everyone. It's been hard without a good teacher and it's a major break though having answers and people that'll listen. Thank you. Truly."
A logical next step would be converting those `if` statements to the Gang of Four State design pattern, then you'll *really* be animating like a programmer
your example works with a simple two direction character, if you just flip it. how would you handle a character which faces 8 directions? (so we have 8 different walk/attack/idle animations)
Great concise presentation! Just keep in mind that this makes your entire animation system pretty hostile to non-devs in the team, and for stuff like delay between transitions and whatnot you can always fix that in the Animator (putting transition time at 0s, not waiting for previous state to end, etc).
Sounds like 10x more code to achieve the exact same result my guy. As I've mentioned in a lot of replies here, I love FSM and use them regularly. Where I don't use them are character controllers (and now, animation). You may look at the wall of bools and get the knee-jerk reaction of it being unmaintainable. But it really isn't. Want to add a new animation? Just slot it in where you think it should take priority. It's much easier to parse 10 lines of code than to jump between 10 files.
It would be helpful if you add to the title or thumbnail that this video is for Unity, I thought this was about animation in general not a specific way of doing it with Unity
Yes finally something I already know and even use from time to time 😁 I really like this approach, but working with animation dudes the standard way is better, because these fellas don't understand coding and never will xD
dude, this is amazing! im not a animator, im a programmer! this is for me! ty! question, i was wondering if your old tutorial for audio clips still apply today?
Can you do a video on how to make different kinds of teleportations? I want to make a 2d character teleport from holding the button, and you see the body in a grayed out form go back and forth from the character to the distance you can aim the teleport. And I wan t to make a teleport where you press it, and the character just pops in at a new location in front of you, but with a marker that you place for teleporting, kinda like a gun, but. you press it to mark the spot, you hold it to teleport there.
How much does int hashing improve performance? Lets say we have a robust system for the player so animations for jumping, falling, transitioning, sliding, walk/running, wall running , etc. As your example is, with pixel art specifically. How do you know when int hashing is worth the time investment?
It's a lot easier to just create your own animator yourself, especially for spritesheet-based animations. Do a foreach loop with each sprite and wait some time (depending on how much you want the animation to take)
@@Tarodev I mean a situation when bool will not switch back automatically. Like after attack or getting hit. F.e., if i get hit from OnTriggerEnter(), what should i do about get_hit animation? Run some delayed invoke, which will switch it off?
Well, i could check for every "true" boolean if it's clip is being played: GetCurrentAnimatorStateInfo(int).IsName(string) and, if so, to switch it off, if it's GetCurrentAnimatorStateInfo(int).normalizedTime > 1f . What do you think?
Very useful, I'm gonna try this method, but for a 3D game. Just a tiiiiny criticism, because I see this done in so many pieces of code: why try to shorten the var names so much that they become confusing? For instance, "private Animator _anim;". That should be "private Animator animator;", "anim" is confusing since it could also be an Animation. I see things like that done so much, and I wish people named their vars better.
I personally just started making things and looking up problems as I went. About as practical and un-academic as you could imagine. And as such, cannot recommend a more structured path.
If you’re looking for non-Unity C#, I learned largely by following IAmTimCorey on UA-cam. He was a fantastic teacher for early stuff, and had a few free series on UA-cam where you slowly build a big application that gets your feet wet with a lot of different stuff. I’ve heard his paid courses are great too.
I wasn't convinced until I saw I could bypass trying to line up the animator arrows in the grid
Exactly!
hahaha
I'm comforted knowing I'm not the only one driven crazy by this. I also spend way more time in Shader Graph lining up nodes than I do making actual shaders...
this saves me soooooo muuuuuuuchhhh tiiiime i love this video
@@blameyourm8519😊p . ;blue🔵 h😊) gF/+0=°Phl de₹
I love how this video is under 2 minutes. Quick and straight to the point. Personally, I prefer the tree and have spent a great amount of time mastering it, but for quick prototypes and game jams this would be WAY faster to set up compared to messing with the tree.
Glad you enjoyed the short form content brother 🙏
What do you prefer about the graph/tree? I've only made a couple small projects in Unity, but this approach seems much more convenient to me. Would it be a problem with scale?
@@Glooberloob The strength of the graph/tree I believe would be helpful for 3D games such as combo-ing and whatnot. Also, the Finite State Machine Behavior can be more easily used in conjunction with the graph/tree (I think, correct me if I'm wrong but I find it easier to fix there especially with AI)
I am working on animations literally this second. God sent you
I switched to code-driven animation almost from day 1 of learning Unity after seeing LRG's tutorial on how to avoid Mekanim spiderweb madness. I barely even know how to use the Unity animator at this point. Your string hash to int trick is something I have not been doing though, until now! Thanks!
Got a link to that video?
@@gamedevteacher7065 ua-cam.com/video/nBkiSJ5z-hE/v-deo.html&ab_channel=LostRelicGames
Simple little string based animator state machine. I've extended it a bit for personal use and even implemented parts of yours, but John's does a fine job even just out-of-the-box
Have been programming in Unity for over 6 years and always wrote my own animation system to avoid the issues addressed in this video.
I never heard of CrossFade, this would have solved everything I solved writing my own systems while keeping it connected to the tools Unity Provided. Thank you for showing this!
To return the favor, let me address the following thing I noticed about the video:
About the animation states. I categorize finite state machines into 3 categories:
Level 1: Tracking state by multiple booleans
Level 2: Tracking state by an enum
Level 3: Tracking state / having the logics of states in separate classes.
You were using a Level 1 Finite State Machine. I highly recommend going for a Level 2 or Level 3 Finite State Machine.
The nice thing about having it in separate classes is that you can do simple things such as:
* WalkingStateClass (holds logics of walking)
* FreezeStateClass (changes color when entered, and back when exited)
And to have the player freeze when hit by an object, you only have to:
CurrentState.Exit();
CurrentState = new FreezeStateClass();
CurrentState.Enter();
Because WalkingStateClass is no longer CurrentState, it no longer is being updated so no walking logics is available anymore. Keeping your behaviour simple and preventing complicated bugs.
Very interesting. Thanks for the write up 🙏
Im getting into unity with some friends. Im a professional programmer but this is my first real foray into game dev. My friends are all artists so I handle all the code. This channel is everything I want. I can figure out how to do nearly everything from the docs but never really know if Im following good practice. Most tutorials have been worthless because theyre not written for or by programmers. Loving you channel because its exactly what Ive been looking for
I'm here for you 🙏 enjoy your journey
this looks a lot easier than working with unity animator, it would be great to see a full tutorial on this!
Yes - an explanation of your full code, and what connects to what components, what terms or commands actually do, why you use the techniques and code you use, etc - that'd be very useful to us folk just starting out!
I highly recommend using Playables graphs for 3d animation. It's built into unity (but with little documentation) and offers even more programmer centric design. For instance, you can use animation clips as serialized fields and reuse animation graphs just like you reuse code.
There is extra work needed to get it set up but it gives you so much more control. It also let's you customize transitions so they're not linear!
Animancer takes away most of the extra work and uses playables in the backend.
had to come back with a new channel because the game i was working on last year uses your character controller... thank you for existing btw! hope you're overcoming any stress you're dealing with at this current point in time and that this year goes great for you :)
I thought this was an asset you made and wanted to show off but no, this is straight up base unity functions. How has this evaded me for so long?!?!
It evaded many of us... But we now have the power.
@@Tarodev I will follow you to the ends of the earth, finder of ancient treasures
So much information condensed into a video that's under 2 minutes. Beautiful Taro! And now it feel like a ton of my videos should be refactored to use this method of animating XD
Combining this with the state machine that you showed us = gold!
maybe you make a video about this.would be good.
LockState is probably what I needed. I followed LostRelics version of this in a lil endless runner I made and I noticed animations being overridden. So in the animator I linked necessary ones back to idle, also turning off the autoloop, and then in my if statement checking player states, I stop/prevent the state changing unless it's not one of those animation states. E.g. player is landing from a jump, even if they are grounded, I don't want idle to play since I want the jump animation to finish, if not jumping play idle but when jump is finished in the animator it will go back to idle. Your LockState example essentially does what I wanted 👌
Also I wish beginners knew of this because Unitys spider web is a nightmare and I can't see an advantage over just coding it.
Yo, that was extremely helpful, I saw a video from lost relic games talking about the concept of coding animations, but you took it to the next level
Probably outside of the scope of a quick vid like this, but if you're using a state machine pattern within your own code, changing animations like this can easily be handled more elegantly than a block of if statements, ESPECIALLY if your animation is tied to state.
Just have some sort of "onStateEnter" function on your states where you set your animation.
I use state machines all the time, but I like my current approach more. Way (way) less boilerplate, exact same result.
Good stuff! My current game is a track- based music game so all of my character animating is being done on the timeline for this one, but I'll definitely keep this in my bag of tricks for future projects. The more you can calculate programatically, the better!
This strategy seems ideal for that type of game, so long as you have events being fired for the beats
@@Tarodev Actually, that makes sense. I was just going to make manually animated segments with timeline triggers to branch/loop, but that could potentially help automate at least some of the animation setup. I'll have to weigh my options!
Damn. I wrote my own animation script because I found the cumbersome web of nonsense in the Unity animator not worth the effort for 2D stuff. This seems like it cuts down on that problem though and still allows making the animations in the animation editor. Excellent stuff!
When you say you created your own, do you mean you manually looped through subsets of sprites?
@@Tarodev yeah I tracked time elapsed in the update function and then changed the sprite to the next one in the array when it reaches the duration of a frame. It's pretty basic but it works for the project I'm using it on right now. If I need something more complex though like for a platformer character I will refer back to this video.
Good job making this video, I feel the YT algorithm read me my mind and showed me this when I needed it.
Animate like a programmer is such a powerful sentence. Draw like a skilled math teacher
Why do mathematicians always have such elegant handwriting? 10k hours I suppose...
@@Tarodev skill based
Amazing idea. Animated transitions have not been relevant for some of my games over the past few years. I just created a state machine for the MonoBehaviour and just played and adjusted the animation state in the logic state like you showed in the video. It avoids many of the problems of dealing with animators and having to maintain two different state machines.
Thank you so much for posting videos for intermediate level coding, it’s just what I need!
I gotta test this one
This Channels like finding a hidden gem, informative and quick to the point. Nice content
Holy shit, is this video really only 2 minutes long? It felt much longer, and I mean that in a good way. A lot of information presented very concisely and intelligently. Thank you.
Thanks :)
Hey TaroDev! Great video, honestly struggled with animations and the damn spider webs way too much. Actually checked you out after the blackthornprod 3d game dev video, you were a complete machine in that! Thanks for the video mate, have a good one!
Welcome aboard mate 😊
I've had a bunch of complaints that I threw out too many previous dev implementation in that video, lol.
Woops.
@@Tarodev all good mate, p.s I liked your changes
Oh man! Thank you so much... I love this!
I know nothing about animation or programming. 10/10 video very helpful!
Thanks Captain!
you are a fooking legend!
This is the most useful Unity tip I've seen in a while. Mecanim is a very useful tool for 3D characters, but so much annoying overkill in many other situations.
Glad you liked it
Now that i think about it
CrossFade method is much more managable and easy to setup. Its a great idea
Have fun with it
cheers for LockState idea
Omg this is everything I ever needed as a programmer. Thank you
Enjoooooy
this channel is a blessing ..honestly. superb content.
Thank you ❤️
I have no idea of what I just saw but I like it
I experimented with crossfade on a small game but I noted that the animation can get stuck sometimes. I searched online and found several discussions on the topic. It appears that crossfading a non looping animation can get stuck and does not exit the animation even if you are crossfading another one next.
As someone who uses script-based animation switching (i.e. using it to start an attack or dash animation from idle), you should also keep in mind that you can point the animator to an Animation Tree, allowing you to still use those should you need them. If you have a top-down shooter, for example, you can script the animator to go to an "Attack" animation tree that then uses animator float values for x/y direction to show the correct animation for the chosen direction. This could also work in the example shown here, where you could have two different attack animations depending on whether you're in the air or on the ground,
This is absolutely fantastic, thank you so much! I love doing things through scripting, it just makes so much more sense in my head, and I feel like I have so much more control over how I do things. Never going back to spaghetti trees lol.
Mr Taro, that is fantastic video! Thank you so much for it :D. I had no idea this method exists!
Thanks buddy :)
triggering ocd was my favorite part.
This Is Much Simpler, Thank You! I Almost Started Using Tween Libraries.
Tween libraries still have a huge place in game dev my man. You can use both!
@@Tarodev True!!! :D ✨
Could you consider making a tutorial on 2d procedural generation? Specifically chunking?
Amazing idea. Yes I can.
just one word THANKS
Crossfade is new to me, this seems right up my alley. Great video man 👊👊
Simple, objective and precise.
Thank you Tarodev!
I'm a terrible programmer, but will use this method simply because you made a video on it. Cheers!
I have so much power
Great video, well done. Could u pls explain or make a video on how to achieve this jelly and bouncy player animations?
dude that perfect thank you!
Incredible content!!! Feel like a beginner watching your videos!!! Grow that channel!! Grow like crazy!!!
I'm tryyyyyyiiiinnnnngggg 😂
Another wonderful tutorial. Also well worth the Patreon sub :)
I noticed that ‘wind’ effect you have. I would love to see how you created that ..
I actually stole this directly from: assetstore.unity.com/packages/vfx/particles/epic-toon-fx-57772#description?aid=1011lkRxs
Your channel is pure gold.
Thank you :)
Taro, you handsome devil! I was about to do a video very similar to yours this friday! I'll still do it, though, because it's about 4-directional movement with only coding, but, damn! Talk about collective unconscious!
Subscribed. I'll be waiting for it ;)
@@Tarodev Done! Uploaded it right now! Please go check it out when you have the chance!
For a small game, those if-branching would be fine.
When you go into larger games and optimization (probably what bigger studios would want from a programmer), you will need to start learning code patterns.
State machine is the most common (I think?) for changing anim states.
Yup, FSM. But try not look at the 'ifs' and immediately think 'not maintainable'. It may seem like that... but you'd be surprised. 10 conditions in a row would achieve the same as 10 files, each with 10 lines each in a FSM. Want to add a new state? just slot it in where you think it takes priority and you're done.
I do agree a bunch of if statements looks like bad code, but this really is lovely to work with. Try it out ;)
Thank you man 🖤
Anything I want?
- The video on Quaternions ;P. (Take your time)
- Also you replacing Brackeys on YT.
- ACTUAL IDEA: I would like a revisit of your Ultimate 2D Platformer Controller in Unity, but 3D 3rd Person.
- Lastly, I want you to be happy and loving what you do. Same for all fellow devs!
This is super useful! More of this please :)
Awesome video , will have to try out crossfade
Good point made with the hashing, wonder how much does it save (but I'm too lazy to benchmark it)
it saves a bit, but a other nice thing is if using the cached hash there is no typos, and you can find usages on it
I used Crossfade in a project where I had a problem - the animation wouldn't go through... :(
I was using the finite state machine pattern, and althought the state did change, the animation did not. It only happened on that one project & I haven't found a solution for this.
I have however, came up with an interesting, Any State Transition workaround (also like a programmer. Aint no body got time to hand make this):
1) get all animator states names into an array
2) create a trigger parameter for each state (paramater name is the state name).
3) save these states into a string array
3) create transitions from AnyState (green state) to each state with the corresponding trigger parameter
4) create a function to trigger state by id (reset trigger immediately after if needed)
5) profit
Sounds like you're trying to recreate the experience of crossfade, without crossfade 😂
Another great video! Can we have your take on creating an inventory system? I know this has been done many times before but I love how simple you make complex topics and I'm sure you'll do a fantastic job with inventory. Covering things such as; Setting up the inventory, drag and drop functions on it, reactive UI based on what you have picked up / dropped and maybe some extras such as combining items from that inventory (for example, crafting.) Because these things are used in many games.
how do you bump the player up when he undershoots a jump in a platformer?
As someone who got recommended this and doesn’t use unity, I relate
Thanks for stopping by even though it's not relevant to you :D
"Taro, there's this thing that's be making me crazy for the last six weeks."
~Hmm let me see. Yeah, what you're dealing with IS difficult. At the moment, it's just not that intuitive and it's not your fault if you're having problems. Here, start with *THIS*.~
"Oh dear lord! That's awesome. It's elegant. It's scalable. It.. It.. Just give me a moment."
~Have I done something wrong?~
"No, you just don't understand how it feels when you're playing by the rules and it STILL doesn't work OR when you can't even find the ******** rules at all. Well, I guess you do. I guess that's why you've been making great resources for everyone. It's been hard without a good teacher and it's a major break though having answers and people that'll listen. Thank you. Truly."
Always enjoy your comments, Tristan. They're a roller-coaster
Ah the wonders of concise unity content. love it
A logical next step would be converting those `if` statements to the Gang of Four State design pattern, then you'll *really* be animating like a programmer
True, true. But I love how little boilerplate this strategy uses. Elegance in its simplicity.
I was a bit sceptical the first 0.02 seconds.
Great tip!
your example works with a simple two direction character, if you just flip it.
how would you handle a character which faces 8 directions? (so we have 8 different walk/attack/idle animations)
Thanks a zillion ton, bro! I’m neither a programmer nor an animator, but if I had a choice, I’d rather go with code. 💞 Ciao!
Good choice bb
"Anything you'd like."
You cheeky son of a...
Omg this is perfect, I'd always hated that graph
Great concise presentation! Just keep in mind that this makes your entire animation system pretty hostile to non-devs in the team, and for stuff like delay between transitions and whatnot you can always fix that in the Animator (putting transition time at 0s, not waiting for previous state to end, etc).
cool!
now i just have to learn to program!
Heh, step one :P
Learn carpentry like a dog-walker.
animancer is great i always use it
It's truly amazing. Possibly overkill for sprite sheet animation, but amazing for everything else
This is so helpful!!
This was helpful and motivating, thanks.
Why not use the full state machine pattern and then call the animation changes during state change?
Sounds like 10x more code to achieve the exact same result my guy. As I've mentioned in a lot of replies here, I love FSM and use them regularly. Where I don't use them are character controllers (and now, animation).
You may look at the wall of bools and get the knee-jerk reaction of it being unmaintainable. But it really isn't. Want to add a new animation? Just slot it in where you think it should take priority. It's much easier to parse 10 lines of code than to jump between 10 files.
FSM is all you need. Good day
Ohhh boi this is so good
It would be helpful if you add to the title or thumbnail that this video is for Unity, I thought this was about animation in general not a specific way of doing it with Unity
And what did you think about the video, even though it was entirely useless to you?
That's nice. Thanks!
Here we go again, actually implementing it rn :D
Yes finally something I already know and even use from time to time 😁
I really like this approach, but working with animation dudes the standard way is better, because these fellas don't understand coding and never will xD
dude, this is amazing! im not a animator, im a programmer! this is for me! ty!
question, i was wondering if your old tutorial for audio clips still apply today?
Your awesome m8
Building a network protocol from scratch based on TCP and not an existing library? :')
Very niche, but interesting topic. Too big for a tutorial (unless I want to go many episodes deep)
amazing
How did you get the line to appear behind the character when moving him?
Great thanks.
:22 second mark...This guy knows how to get subscribers
You share the frustration I see 😂
I love you
u 2 bb
Can you do a video on how to make different kinds of teleportations? I want to make a 2d character teleport from holding the button, and you see the body in a grayed out form go back and forth from the character to the distance you can aim the teleport. And I wan t to make a teleport where you press it, and the character just pops in at a new location in front of you, but with a marker that you place for teleporting, kinda like a gun, but. you press it to mark the spot, you hold it to teleport there.
Sounds like a fun mechanic, but a little too specific for a video unfortunately
@@Tarodev oh, okay
anything? literally anything? I'd like an ice cream... thank you.
I never said I'd *give* you anything 😉
How much does int hashing improve performance? Lets say we have a robust system for the player so animations for jumping, falling, transitioning, sliding, walk/running, wall running , etc. As your example is, with pixel art specifically. How do you know when int hashing is worth the time investment?
It's negligible, but working with strings should be avoided wherever possible, so there's no real downside.
It's a lot easier to just create your own animator yourself, especially for spritesheet-based animations.
Do a foreach loop with each sprite and wait some time (depending on how much you want the animation to take)
Can you tell me where you got the assets and art ?
I paid an artist, but I'll be releasing them for free soon :)
How (or rather, when) do you switch back your bool switches, like _attacking?
These are handled by your controller. So for example if your input.x is not 0 your _walking should be true.
@@Tarodev I mean a situation when bool will not switch back automatically. Like after attack or getting hit.
F.e., if i get hit from OnTriggerEnter(), what should i do about get_hit animation? Run some delayed invoke, which will switch it off?
Well, i could check for every "true" boolean if it's clip is being played: GetCurrentAnimatorStateInfo(int).IsName(string)
and, if so, to switch it off, if it's GetCurrentAnimatorStateInfo(int).normalizedTime > 1f .
What do you think?
Delayed Invoke seems to work well, btw.
Did you made the art if not please asset link and if yours then colour you use
Thank you for this video.
excellent vid!
Very useful, I'm gonna try this method, but for a 3D game.
Just a tiiiiny criticism, because I see this done in so many pieces of code: why try to shorten the var names so much that they become confusing? For instance, "private Animator _anim;". That should be "private Animator animator;", "anim" is confusing since it could also be an Animation. I see things like that done so much, and I wish people named their vars better.
This might seem somewhat random, but, what's a good place to learn C# online? paid, or otherwise?
I personally just started making things and looking up problems as I went. About as practical and un-academic as you could imagine. And as such, cannot recommend a more structured path.
If you’re looking for non-Unity C#, I learned largely by following IAmTimCorey on UA-cam. He was a fantastic teacher for early stuff, and had a few free series on UA-cam where you slowly build a big application that gets your feet wet with a lot of different stuff. I’ve heard his paid courses are great too.
This is neat, is using Crossfade() over Play() more efficient?
Crossfade lets you specify an animation blend duration. Play will just run the new animation instantly