Search Unity

Question Which path-finding approach should I go with for a 3D grid map?

Discussion in 'Navigation' started by Ularis, Aug 9, 2020.

  1. Ularis

    Ularis

    Joined:
    Dec 22, 2019
    Posts:
    23
    I'm currently working on a dungeon crawler game based on the old school grid system. Think of Dungeon Master or the more recent Legend of Grimrock.

    I'm trying to figure out which approach should I go with, to implement a decent path-finding system. What is puzzling me is that, since the game's map is hand crafted, I don't actually have "map" object holding the locations of all walls and paths. Instead, the scene is made of 3D cudes. So, I have a few questions:

    1 - Do I need need to have an array like object to hold all the positions of these 3D cubes? If so, would this be done by looping through all gameObjects to collect their positions and types (walkable, obstacle), at run time?

    2 - Is it possible to have a Navigation Mesh work with grids? The Navigation Mesh system is really easy to use but I'm not sure how to make it work with nodes (tiles).

    I'm new to unity. Perhaps there an easier approach to implement what I describe. I've looked into Unit's assets but I don't wont to buy anything without make sure it fits my needs. I need more knowledge on how this should be implemented before I can decide anything.

    Thank you for any feedback.
     
  2. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,749
    You should grab the Unity NavMesh Components from GitHub https://github.com/Unity-Technologies/NavMeshComponents , it allows alot more control over navmesh functionality, read the documentation on them, should help you. Heres the functions:

    NavMeshSurface – for building and enabling a NavMesh surface for one agent type.
    NavMeshModifier – affects the NavMesh generation of NavMesh area types, based on the transform hierarchy.
    NavMeshModifierVolume – affects the NavMesh generation of NavMesh area types, based on volume.
    NavMeshLink – connects same or different NavMesh surfaces for one agent type.

    Check it out, might help you :)
     
  3. Ularis

    Ularis

    Joined:
    Dec 22, 2019
    Posts:
    23
    I've tried mesh, but I don't see how I can make it work with a grid map.
     
  4. Skynet766

    Skynet766

    Joined:
    Sep 13, 2020
    Posts:
    22
    What I did when I needed grid based movement:
    - Work out how wide the grid tiles are
    - Raycast down from the centre of the tiles to see where the floor spaces are
    - Check for each collision point if there is actually space for the character to stand
    - For adjacent collisions work out if there is room for the AI to move to that space/tile