There's more...

We have used a simple trick in our Warrior2dMove.cs script to lower the number of required animations. Our character can move left and right, but we use only one animation: Warrior2dWalk (in which the character is moving right). In the script's Update() function, we check if the player Horizontal axis input is greater than 0 or less than 0 and set the local X scale of the character to 1 or-1, depending on the movement direction. This flips the character and saves us around 50 percent of the animations:

if (hor > 0f) 
{ 
     transform.localScale = Vector3.one; 
} 
else if (hor < 0f) 
{ 
    transform.localScale = new Vector3(-1f, 1f, 1f); 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.43.126