Advertisement
Guest User

Untitled

a guest
May 27th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.     hexHeight = size * 2;
  2.         hexVertDistance = hexHeight * 3 / 4;
  3.         hexWidth = Mathf.Sqrt(3) / 2 * hexHeight;
  4.         hexHorizDistance = hexWidth;
  5. void Start()
  6.     {
  7.     position = HexOffset((int)locationInArray.x,(int)locationInArray.y);
  8.         transform.position = new Vector3(position.x, position.y);
  9.     }
  10. public Vector2 HexOffset(int x, int y)
  11.     {
  12.         Vector2 position = Vector2.zero;
  13.  
  14.         if (y % 2 == 0)
  15.         {
  16.             position.x = x * hexHorizDistance;
  17.             position.y = y * hexVertDistance;
  18.         }
  19.         else
  20.         {
  21.             position.x = (x + 0.5f) * hexHorizDistance;
  22.             position.y = y * hexVertDistance;
  23.         }
  24.  
  25.         return position;
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement