コード例 #1
0
 void LateUpdate()
 {
     doTouch();
     if (currentJoystick)
     {
         Vector2 axys = currentJoystick.GetAxys();
         vert = axys.y;
         hor  = axys.x;
     }
     else
     {
         vert = Input.GetAxis("Vertical");
         hor  = Input.GetAxis("Horizontal");
     }
     dir = Direction.None;
     if (Mathf.Abs(vert) > Mathf.Abs(hor))
     {
         if (vert > offset)
         {
             dir = Direction.Up;
         }
         if (vert < -offset)
         {
             dir = Direction.Down;
         }
     }
     else
     {
         if (hor > offset)
         {
             dir = Direction.Right;
         }
         if (hor < -offset)
         {
             dir = Direction.Left;
         }
     }
     anim.SetInteger("Direction", (int)dir);
 }