2D boy animation
This video is about one of the ways to create two-dimensional animation in Unity, which does not use any assets.
Sample pictures
C# code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | using UnityEngine; public class player : MonoBehaviour { private Animator anim; // Use this for initialization void Start () { anim = GetComponent<Animator> (); } // Update is called once per frame void Update () { if (Input.GetMouseButtonDown(0)) { Idle(); } if (Input.GetMouseButtonDown(1)) { Bend(); } if (Input.GetMouseButtonDown(2)) { Walk(); } } public void Idle() { anim.SetBool("bend", false); anim.SetBool("walk", false); } public void Bend() { anim.SetBool("bend", true); anim.SetBool("walk", false); } public void Walk() { anim.SetBool("bend", false); anim.SetBool("walk", true); } } |