Advertisement
Guest User

darren

a guest
Oct 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1.     Vector2 movement = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal"), CrossPlatformInputManager.GetAxis("Vertical"));
  2.  
  3.         //Vector3 movement = new Vector3(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"), 0f);
  4.  
  5.         if (Mathf.Abs(movement.x) > 0.2 || Mathf.Abs(movement.y) > 0.2)
  6.         {
  7.             if (Mathf.Abs(movement.x) > Mathf.Abs(movement.y))
  8.             {
  9.                 //right
  10.                 if (movement.x > 0)
  11.                 {
  12.                     rightPressed();
  13.                 }
  14.                 //left
  15.                 else if (movement.x < 0)
  16.                 {
  17.                     leftPressed();
  18.                 }
  19.             }
  20.             else
  21.             {
  22.                 //up
  23.                 if (movement.y > 0)
  24.                 {
  25.                     upPressed();
  26.                 }
  27.                 //down
  28.                 else if (movement.y < 0)
  29.                 {
  30.                     downPressed();
  31.                 }
  32.             }
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement