Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

A* Pathfinding in 2D platformer with changing tilemap

Discussion in 'Scripting' started by Emolk, Dec 2, 2019 at 7:22 AM.

  1. Emolk

    Emolk

    Joined:
    Feb 11, 2014
    Posts:
    113
    Hi, i noticed on the A* project page that graph updates only include 'only existing nodes'. Does that restrict the path finding to only nodes that are created in the inspector?

    In my game the Player can place and destroy tiles whilst playing. Is it possible to implement AI that follow A* pathfinding with this in mind? Is there an easier solution to my problem?

    Thanks.

    Also, is this Brackey's tutorial from 2015 still relevant?



    Or should i look for another tutorial to start off?
     
  2. Emolk

    Emolk

    Joined:
    Feb 11, 2014
    Posts:
    113
  3. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    1,499
    Most people on this forum will not be familiar with any given tutorial that you happen to be following. I suggest asking the tutorial author, or rephrasing your question in such a way that it could be answered without being familiar with the tutorial.
     
  4. Emolk

    Emolk

    Joined:
    Feb 11, 2014
    Posts:
    113
    The tutorial question is a sub question of my main question and is mainly irrelevant. The main question is is it possible to implement the Unity A* Pathfinding Project found here: https://arongranberg.com/astar/, with a Tilemap that changes throughout the game? IE can i update the graph when the Player changes the tilemap, and if so, will it causes framerate issues?

    Iv'e found that navmesh cutting is only available in the pro version: https://arongranberg.com/2013/08/navmesh-cutting/

    However since my game is 2D maybe graph updating won't cause issues anyway?
     
  5. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    1,499
    OK, so you're not asking about a specific tutorial, you're asking about a specific third-party plugin. You've still got the basic problem that the audience you are asking (i.e. people who know about Unity scripting) is not a very good match for the set of people who would actually know the answer to your question (i.e. people who know about that exact plugin).

    I suggest you ask the plugin author.
     
    Emolk and Kurt-Dekker like this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    4,534
    Yes: you simply keep the tilemap in sync with the graph, and vice-versa.

    I doubt it, but the profiler will always know best.

    Updating a graph when a tile changes should be an O(1) operation: you go to change the tile, you go to that node on the graph and disconnect (or reconnect) the appropriate links to other nodes, or else set its node cost to infinite.
     
    Emolk likes this.