Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1.   private int DetermineDiceFace()
  2.     {
  3.         Vector3 upDir = Vector3.back;
  4.         float x = Vector3.Dot(transform.right, upDir);
  5.         float y = Vector3.Dot(transform.up, upDir);
  6.         float z = Vector3.Dot(transform.forward, upDir);
  7.  
  8.         float xAbs = Mathf.Abs(x);
  9.         float yAbs = Mathf.Abs(y);
  10.         float zAbs = Mathf.Abs(z);
  11.  
  12.         if (xAbs > yAbs)
  13.         {
  14.             if (xAbs > zAbs)
  15.             {
  16.                 return x > 0 ? 1 : 6;
  17.             }
  18.             else
  19.             {
  20.                 return z > 0 ? 2 : 5;
  21.             }
  22.         }
  23.         else if (yAbs > zAbs)
  24.         {
  25.             return y > 0 ? 3 : 4;
  26.         }
  27.         else
  28.         {
  29.             return z > 0 ? 2 : 5;
  30.         }
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement