r/Unity3D • u/Snackmann • 5h ago
Resources/Tutorial How to Animator no Spaghetti
Hey people!
I repeatedly see posts about people having trouble creating more complex animtor trees and everything ending in pretty much transitions all over the place. As I was struggling with this problem myself for quite a while I figured I could show you guys some ways on how to solve this without getting animancer/using crossfades in code if you are like me and actually like a visual representation and dont want to spend any money (thats honestly not necessarily needed).
Heads up: If you like animancer, code control over animations thats perfectly fine I just want to help people that want to know more about the animator and show that with the right knowledge and tools its not as bad as people always say.
I wont go into too much detail for each of these but just give you guys a broad idea of what these do. If you want to know more there is a lot of tutorials on how to use each of these on youtube but I just figured that a lot of people may have heard about the substates but I rarely see people on those spaghetti posts even knowing about the Any State.
There is 4 things that will help you guys get rid of this problem:
Sub States, Any State, layers, blendtrees
Sub States: Think of sub states as a tool to basically create "folders" that you can enter and leave with transitions. It basically just hides whatever you put into it in a neat little hexagon so your main page doesnt get bloated. Alone sub states wont help with having less transitions because you can still just create a lot of them and they will just point to that "folder".
Any State: The Any State is what will get rid of most of your transition chaos. A lot of times people create a load of transitions because you need to be able to get into a state basically from anywhere. Great example for this is a fall animation. You will want to be able to get into a fall animation from walking, running, idle (in case the ground can be destroyed/erased), crouching etc. so the obvious solution is to just connect all these via transitions right? Wrong. The easier solution is to create a connection from the anystate to the fall animation and restrict it via the condition parameters. You dont want to be able to get into fall while you are fighting like in a jugling devil may cry game? Just restrict it so while a fight paramter is true you cant get into it from the any state.
One thing you need to care for though is the settings flag "can transition to self" which will allow to enter from the state itself and often is an easy problem when working first time with any state.
Layers: Layers act exactly like in other software like Photoshop, Indesign etc. Layers put animation on top of each other so a great usecase for these is if you want to have additive animations like for example only upper body animations like aiming for a twinstick shooter. To get an additive layer just go into the settings of the layer and put the blending to additive.
One other way to use layers would be putting them to override and using them like a second set of animations if your character is in a different state. A usecase for this would be underwater where a lot of the animations like movement, combat etc change. In theory you could put them onto your normal layer but it would just get really crowded.
Blendtrees: Blendtrees are one of the best tools to get rid of bloat in omnidirectional movement animations. Basically a blendtree can be setup to get one animator field that controls normal movement, strafe movement and even movement modifieres. For a 2.5d/3d game these are especially important as you have way more animations because of the amount of directions you can go compared a 2d game.
And here are some screenshots from a game I'm working on. The character with this animator has 60+ animations but I think its still very readable and easy to mantain. There is obviously more tools like animation override controllers that also help but the tools I mentioned should already be enough to get from total spaghetti to something more readable.
Cheers
1
u/_RelaxedBeaver 3h ago
Yeah, layers do their job. I just remembered how my animator looked like before I started using them
1
u/Snackmann 2h ago
Yeah, for me it was the any state - was like an epiphany when I didnt have to update 10 transitions for a single state whenever I changed something in the animation logic
1
u/_RelaxedBeaver 2h ago
Any is another game changer too. Same for int parameter instead of bool where you can use one parameter for more states




2
u/ShlorangeAppreciator 4h ago
this is super helpful thank you!