I use the following code for moving and animating my 2d topdown player. Its animator consists of 2 blend trees: idle and walk. Each blend tree is set to 2d simple directional, and has 4 directions. It works almost perfectly, but when I am pressing more than one key, some animations are prioritized over others. Like when I´m moving down and right, the down animation shows, but when I´m moving up and right, the right animation shows. How can I make so that the first key that I pressed is the one shown as an animation?
Only consider the code AFTER you have done this critical step:
Always start with the Animator state machine and prove it works in isolation, no code at all.
Here’s more reading:
Sounds like you wrote a bug… and that means… time to start debugging!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.