In this tutorial We want to see how to animation moving character(player) in a 2d platform game on unity engine with easy c# scripts.This tutorial we can learn step by step process to move the character(player) in 2d game.I wish you can learn this easily.I will explain with screenshots and videos.Lets go to tutorial.Its not much harder
Before enter this tutorial you want see these tutorials
1.You know how to move and flip the player.now i am going to tell you to how to animate the player while moving.
2.click the player in the hierarchy
3.in the animation tab click create and save as idle
5.drag all running images to the run script (download here{you want to slice the runinng image watch video here})
6.make your you enable the show sample rate
7.adjest the value of sample to adjest the speed
8.now go to animater tab
9.make transection each other to run and idle by right clicking and clicking the make transection
10.now click the plus simbol in the parameter and click bool and name it as isrun
11.now click each trasection and do following
⦁ off exit time
⦁ untick fixed duration
⦁ make trascetion duration to zero
12.add each contition to each transection arrow
⦁ idle to run arrow -make contition as isrun true
⦁ run to idle arrow -make contition as isrun false
13.Ok now open the playercontroller.cs script and add those thing
Create variable=> public bool isrun=fasle;
Animater=anim;
In start mathord=> anim= GetComponent<Animator>();
In the update methord=> if (Input.GetAxis("Horizontal") != 0)
{isrun = true;}
else
{ isrun = false;}
anim.SetBool("isrun", isrun);
14.then start the game.If any error comment me(download script)
Check it in this tutorial in this video,
⦁ you can watch how to move player in this link here
⦁ you can watch how to flip moving player in this link here
Watch tutorial to download Unity Engine here