2

I have a unity state machine with four states: idle left, idle up, idle down and idle right.

transitions

To transition between these states I had to create 12 transitions. (the white arrows). This already seems unwieldy, but now I need to add 4 more states: running up, running down, running left and running right.

Does that mean I end up with 8 states and 24 transitions running between all of them? That seems very unwieldy to me. What if you need to change something later?

I know I can transition by code, but that doesn't seem to be the recommended way of working.

animaor.Play("runningright");

What would be the recommended way to work with lots of states?

Kokodoko
  • 26,167
  • 33
  • 120
  • 197

1 Answers1

2

As @Uri Popov said, you should consider using "Blend Trees". They are there for the same purpose. The help blend between multiple similar animations. for example, walk and run animation are similar in a way that they depend on character's movement speed.

Look at the following links to learn more about blend trees. These are only basic but will surely help you with your problem.

  1. Unity - Manual: Blend Trees
  2. Blend Trees - Unity Official Tutorials
  3. When to use a blend tree vs state machine for animations (just another question on gamedev.stackexchange)
Community
  • 1
  • 1
Anas iqbal
  • 1,036
  • 8
  • 23