So I’m trying to make animations for a player.
I already have the moving animation for 4 directions and idle animation for 4 directions.
I’m using the animator and transition bars to do this. However, I realize this will probably take like 56 transition bars and that sounds super inefficient.
What I want to accomplish is that:
if player walks left and then stops, then player switches from leftWalk to leftIdle.
if player walks left, then walks right, then stops, then the player switches from leftWalk to walkRight, then idleRight.
the player moves accordingly if wasd or left,right,up,down key is pressed and when none of the keys are pressed, the player faces the direction it was previously walking toward (idleDirection).
I have 3 int parameters, walkDirection, idleDirection, and previousDirection(for storing the previous int value of walkDirection and set it equal to the idleDirection).
I’m assuming that you’re using sprites, since otherwise having separate animations for walking left and right makes no sense. If you’re in a 3D world, just rotate your character, and use the two animations.
What you want with sprites is blend trees for each direction. Set up your tree with four blend trees: right/left/up/down, and set up transitions between them based on the direction you’re moving in.
Within the trees, add the corresponding walk and idle animations. Blend based on the speed of the character, and set the threshold to be discrete - that is, either idle or walk, no in-between.