A* Pathfinding Project

2D platformer with changing tilemap


#1

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

Hey,

You can update pretty much anything during run time. That includes new graphs, new nodes, new connections etc.

To place object dynamically there are 2 solutions.
https://www.arongranberg.com/astar/documentation/spherical_4_1_20_17f940b2/navmeshcut.html
This will cut a hole in the navmesh, to indicate agents that they have to go around.

https://www.arongranberg.com/astar/documentation/spherical_4_1_20_17f940b2/turnbased.html
Allows you to block certain nodes. Great tool if you want to build a tower defense game, where the player can’t block the path for the enemies.

I’ve skipped through Brackey’s video, and yes following this would still work. Though you can always just follow the uptodate Get Started page.

I do want to highlight that this tool doesn’t have any 2D platformer specific tools. Many people made used the Node-Graph to create platforms, which does work. But there is no automatic generation of these components.


#3

Thanks mate appreciate your reply.

The game is a 2D procedural generated platformer where the player can place and destroy tiles in the tilemap.

Could you point me in the right approach to incorporate those elements?


#4

Depends on how your procedural system would work.
if you’re using a pool of predefined level sections that are just chained together.
You could manually make the point graph for each section. Then write a script to link the new map tile to the previous section: https://www.arongranberg.com/astar/documentation/spherical_4_1_20_17f940b2/pointnode.html#AddConnection

If your levels are truly procedural and just follow a set of rules, you’ll have to write a script to detect placement of these PointNodes.

There aren’t any great resources for this A* PP 2D platforming specifically.


#5

Hmm ok thanks, i’l look into it. If i have say a 2000x2000 world, will it slow down hugely, or is not that heavy?

It’s true procedural with perlin noise btw with an easily adjustable world size.


#6

That’s definitely a large world.
You could take a look at the procedural grid mover.
It allows you to make a smaller grid that moves with the agent / player.
So only the the area around the main player will be calculated.


#7

Yep definitely looks like what i’m after, thanks a lot!

Also how can i tell if its in the free version or pro version as i’m not sure how to tell?


#8

Everything mentioned in this thread is in the free version.


#9

Hi sorry i’m struggling to figure out how to use Navmeshcut. I can’t find it as a component or a class anywhere after importing A*. How do i implement Navmeshcut?


#10

Hi

The navmesh cut component exists in the pro version only. Do you have the pro or the free version?


#11

I have the free version. Do you know how i can accomplish my goal with the free version?


#12

You could always rescan the area where the object was placed. Take a look at https://arongranberg.com/astar/docs/graphupdates.html

Sorry for the late reply


#14

Thanks for the link! I simply call this function whenever i delete or create a tile and it works like a charm!

public void TileUpdate(Vector3 pos){

        // As an example, use the bounding box from the attached collider

        Bounds bounds = new Bounds(pos, new Vector3(1, 1, 1));

        var guo = new GraphUpdateObject(bounds);

        // Set some settings

        guo.updatePhysics = true;

        AstarPath.active.UpdateGraphs(guo);

    }