#Ai pathfinding problems

1 messages · Page 1 of 1 (latest)

frail lance
#

hello,I’m following this 3 part platforming tutorial link: https://youtu.be/ydOKPX7t3XM?si=FNg31Q1K1ZF6nxnF
, but it’s a bit outdated, and I’ve run into an issue with the graph logic in Godot.

I’ve got “fall-down” points that are generated below platforms via raycasts these are points that let the character drop down to lower tiles. The problem is these points aren’t detecting or connecting to the closest point to their right.

This is the second of a 3 part tutorial showing how to make a pathfinder that should be able to use any tileMap. This video goes over connecting the graph points to map out where the character can travel.

Part1:
https://www.youtube.com/watch?v=OBBLgrhvaIo&ab_channel=Arithmetic

Finished Project (GitHub)
https://github.com/MyNameIsntBob/2D_Plat...

▶ Play video
#

thank you

#

@open bone hello

#

im quite new to godot and gamedev so some things in my script might not be formated the standard way

frail lance
frail lance
#

my head is about to explode

#

I think I should've tried finding a more updated tutorial

tight sun
#

The logic there is hugely opaque.

I think the call to cell-type is probably looking in the wrong place.

#

(also - can you save your gd script with a txt extension and repost the link? Or chuck a gist up. I'm on my phone at the moment and it has an... interesting interpretation of .gd files 😕 )

frail lance
#

also i live in the asia part of the world so my replies may be sent really late very sorry about that too

tight sun
#

This still looks opaque to me. You might want to start by rewriting cell_type to only work in one fashion - without mutating its pos parameter - and change the calls to it to pass in an appropriate position.

Other than that, I'd put breakpoints on the _draw function and single-step. If you set up a trivial tilemap with just a single example that's breaking it should be easier to track what's going on.

FWIW for most tilemap sizes, eliding the intermediate points in a horizontal stretch might be considered a complicating optimisation. Worth checking the astar behaviour without that.

frail lance
# tight sun This still looks opaque to me. You might want to start by rewriting cell_type to...

"This still looks opaque to me. You might want to start by rewriting cell_type to only work in one fashion - without mutating its pos parameter - and change the calls to it to pass in an appropriate position."
I will delete the IsAbove function and IsGlobal statements inside the cell type since they are the ones messing with the positions.

I’ll experiment with breakpoints and see if they help me figure out anything.

As for the comment, “FWIW for most tilemap sizes, eliding the intermediate points in a horizontal stretch might be considered a complicating optimisation. Worth checking the A behaviour without that” .

May I ask why it’s considered a complicating optimization? It seems like it would make things easier to spot and isnt too intensive.
In this case, the optimization is just a single line of code whcih also isn’t very messy. For example, I wouldnt be able to easily identify which points are problematic and why. From the screenshots above, you can see it’s just the drop down points that aren’t searching for the closest point to the right. However, if I fill in that gap and that point disappears, the points that aren’t drop down points detect the next one, meaning the positions for all the points are fine.

#

thank you so much for the reply btw

#

made the map smaller and experimenting with breakpoitns as of right now

#

ok the breakpoints helped me identify here the problem was, now i just need to figure out hy

#

ur suspicion is right, it might be the logic problem, because, when finding and setting closest right, it was never able to, probly something about the dro don points didnt allign with nay of the ifs. or im using breakpoints wwrongly

tight sun
#

look at the return for cell_type

frail lance
#

i may hve found the root cause, in the if statement, it wsa tryign to detect Type but someho dropdown points either return null or nothing for celltype

frail lance
tight sun
#

I think it's not quite right.

#

(or, how you're using it when you connect up the points in _draw is wrong)

#

also I think there's another problem with this in that if you have a setup like this:

#### ########## #####

    A   # #    B
######### ############

then I think it'll connect A and B.

frail lance
#

here it eorks no after removing if type statement

tight sun
#

(although you might get intermediate positions that prevent that.)

#

as to the "why I'm not sure skipping horizontal segments is a good idea" - (a) it is clearly making the logic here quite a bit harder to reason about compared to just checking neighbouring points; (b) there's a small complication when you're route-finding if you end up between points.

#

But, what I'd do here is factor your "find next neighbour" into its own function because then you can call it from the evaluator once you hit a breakpoint

frail lance
frail lance
#

for now i dont really know why it detects celltype[1] as 0 but doesnt detect cell type at all but i think this situation, if it works it works

#

thank you so much for the help btw, i finally get to continue, and i learnt how to use breakpoints

tight sun
#

Incidentally here's one that I put together that drives the heartbeast controller with a little pathfinder:

#

The connection map for this looks quite complex but a* works fine:

#

Good luck - do post updates in #1235168195275391036 !

frail lance
tight sun
#

not in the slightest.

frail lance
frail lance
tight sun
#

A* is really good, even when it's navigating a maze like this one. There aren't many decision points (connections) between individual nodes and it just blazes a trail in "roughly the right direction"

frail lance
frail lance
#

Also how do I mark this post as solved

tight sun
#

if this was a thousand times bigger I'd probably break the problem into chunks: use a local a* to navigate within a region and a larger one to navigate between. But for games at a scale where it doesn't just turn into the ninja equivalent of a walking simulator, the single one is fine. The map's about 35*50 and has about, er, 450 points and around 1200 connections (in total), so between 2-3 conenctions per point.

#

I dunno about the "how to mark as solved" but I've asked in quick-help. Anyway - nice talking to you! Hope to catch up again in the near future.

frail lance
#

Goated

#

Ai pathfinding problems tag

#

Ai pathfinding problems

#

Yea no I'll try to add the tag when I'm on my pc