Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AStar 2D tile array

Discussion in 'Navigation' started by osho872, Dec 22, 2020.

  1. osho872

    osho872

    Joined:
    Dec 8, 2020
    Posts:
    8
    Hi all,
    i am just starting to get deeper into unity after finishing some tutorials.
    In my 2d top down rpg i want to use pathfinding. AStar 2D seems like a good solution. I do however struggle with the simple manual of setting it up.

    I am supposed to create a two dimensional array of my tile objects (im inherting TileBase for that).
    The index of the array is supposed to be X and Y.



    Unlike in their manual, i dont have gameobjects as tiles. I am using the tile palette and have therefore inherited from TileBase, not MonoBehaviour.
    Therefore, I also dont instantiate the tiles from the code as seen in the loop, but retrieve them from my Tilemap earlier on (i hope im not doing anything wrong here)

    I am now stuck with filling that two dimensional array though. My tiles positions do ofc have negative x and y values too. Do you guys know how that array is supposed to be filled in real life scenarios where you dont just create new tiles from prefabs starting at x and y 0 like in the tutorial?

    this question must be terribly stupid...
     
    Last edited: Dec 22, 2020