Search Unity

Space grid effect

Discussion in 'Editor & General Support' started by Vanz, Jul 31, 2014.

  1. Vanz

    Vanz

    Joined:
    Nov 19, 2013
    Posts:
    374
    Hi,

    I have a space back ground that I am tiling, so the user can move in all directions infinitely, now what I would like to do is add a grid and numbering system as shown below in Unity.

    Any ideas on how to get these grey lines to best appear, I was thinking of using a large texture with the center squares transparent, but I want the user to be able to stroke and move on a tablet in any direction and have the sectors shown below go very high, not infinity but in the thousands...

    Also, I'm wondering how to best handle displaying the sector numbering in Unity, I could add a GUI text object but was wondering if there is a better way to handle this situation in Unity. Start of game is sector 000 where earth is, all other sectors project out from there.

    Hope that made sense...

    Vanz

     
    Last edited: Jul 31, 2014
  2. crag

    crag

    Joined:
    Dec 13, 2013
    Posts:
    145
    I would think Vectrosity and TextMeshPro would be your best bets.
     
  3. Vanz

    Vanz

    Joined:
    Nov 19, 2013
    Posts:
    374
    Thanks Crag... those are both assets I would need to buy I take it?

    Any other ways?
     
  4. crag

    crag

    Joined:
    Dec 13, 2013
    Posts:
    145
    Yes, for purchase. But both very useful, well-supported assets. Eric has probably already done what you are proposing here.

    Keeping it "free", consider...

    For the grid, you could study this: http://wiki.unity3d.com/index.php/DrawLine

    For the numbering system, you could create a prefab with a GUI textfield in top left corner, then iterate through a loop whatever number of columns and rows necessary and instantiate said prefab and populate its grid number based on values generated in that loop.

    Warning, pseudocode ahead!

    Code (JavaScript):
    1.  
    2. var prefab : Transform;    // create a new clone of this object
    3. var vectorPosition : Vector3;    // where to put the clone
    4. var numRows : int = 100;
    5. var numColums : int = 100;
    6. var counter : int = 0;
    7.  
    8. for (var i : int = 0; i < numRows; i++)
    9. {
    10.     for (var j : int = 0; j < numColumns; j++)
    11.     {
    12.         // too late to google "spiral matrix" right now, I leave this bit for you to figure out :D
    13.         vectorPosition = Vector3(x, y, z);
    14.         var prefabObject = Instantiate (prefab, Vector3(vectorPosition.x, vectorPosition.y, vectorPosition.z), Quaternion.identity);
    15.         prefabObject.name = prefab.name + "_" + numRows + "_" + numRows;
    16.         prefabObject.labelValue = counter;
    17.         counter++;
    18.     }
    19. }
    20.  
    Write a script to attach to the prefab that formats and puts the "labelValue" in that GUI textfield. Obviously, your placement of the prefabs would match up with your vector line "grid" system.

    Question: if they can swipe in any direction, does that mean the camera is basically in the center of a spherical grid? Or are you gonna try to keep things linear/parallax (like the above)?
     
    Last edited: Aug 1, 2014
  5. Vanz

    Vanz

    Joined:
    Nov 19, 2013
    Posts:
    374
    Thanks Crag, will look into...