Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Help with A*

Discussion in 'Navigation' started by unity_7D722ACF0D2F719D794B, Feb 13, 2023.

  1. unity_7D722ACF0D2F719D794B

    unity_7D722ACF0D2F719D794B

    Joined:
    Jun 28, 2022
    Posts:
    3
    I'm trying to implement an A* algorythm and i've run into 2 problems:
    1.how do I generate the nodes? I've managed to do it for stuff like a cube, but idk how to do it for smth more complex (irly dont wanna use mesh colliders if i can)
    2.should i put all the connections between nodes in a matrix or should i put in every node a list of the adjacent nodes? when the scene begins i wanna delete the nodes with no conections to others; also im thinking to add the start and end position as temporary nodes and calculate the path that way
     
  2. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    I recommend watching a series of videos by Sebastian Lague about A* Pathfinding. The link to the introductory video is here.

    Both of your questions are answered, including a lot more. I believe it is probably the best A* Pathfinding series on Youtube.
     
  3. unity_7D722ACF0D2F719D794B

    unity_7D722ACF0D2F719D794B

    Joined:
    Jun 28, 2022
    Posts:
    3
    how would i do the node creation in 3d? making a 3d grid seems rather ineficient
     
  4. ElevenGame

    ElevenGame

    Joined:
    Jun 13, 2016
    Posts:
    128
    You can make a graph of 3D nodes, that might save you a lot of memory compared to a grid.
     
  5. Elhimp

    Elhimp

    Joined:
    Jan 6, 2013
    Posts:
    34
    Octree