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

A* Pathfinding in 2D platformer with changing tilemap

Discussion in 'Scripting' started by Emolk, Dec 2, 2019.

  1. Emolk

    Emolk

    Joined:
    Feb 11, 2014
    Posts:
    241
    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:
    241
    Bump
     
  3. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    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:
    241
    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:
    2,836
    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:
    38,520
    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.