(BUG) Wrong path is generated when start and end are too close


#4

Hi

Which version are you using? It looks like it might be an older one. I know the point graph has had a few bugs in earlier versions related to finding the closest point in point graphs.


#5

Hi

Version 4.2.4 (2018-12-03)


#6

Hi

I’m not sure what could be going wrong here. Perhaps you could share a simple test scene with me and I could have a look?


#7

I already did.

Here is the Git Hub I’m working on https://github.com/ertsnom99/plateformer.
I’m using Unity 2018.2.8f1. Try the scene named BossFight and just jump to the middle platformer and you will clearly see the issue

Also, here is an other capture of the issue:


#8

from just looking at your picture i don’t see much use for path finding and i believe you would make benefit more from the use of physics.

the way your nodes are spaced out maybe your picking a starting node that isnt actually somewhere the fox would be standing.
consider using a grid graph if the fox can move independently of the pathing script


#9

On the contrary, the point graph is perfect for my needs (considering this is a prototype). Plus, I don’t get what you mean by “the use of physics”… Do you mean moving the character? Because that is handeled separetly (there is a complete seperation of moving (done by my scripts) and finding the path that the character should take (done by Pathfinding project))

A grid graph is a bad idea (for an AI that can jump from a palteforme to an other (it’s way better for flying ennemis)), because it is most likely to not do strait line when going up to a plateforme, which would make the process of reaching the target needlessly to complicated. Strait lines are perfect since the x and y component can be use to decide to either jump (and how much) or just let the character fall of the paltform.

There are other ways to make pathfinding for AI for platformer, but they would take to much time for just a prototype.

The real issue here is that it just seems to have a bug. It should simply find the closest position along the path and start from there, but, has you can see, it doesn’t. Either way, someone else was bound to have the same problem, so better fixe it now! :slight_smile:


#10

what i assume is happening is that say the fox has a node to the left and the right of him, you want him to move right but the left node is closer to him, so he starts his path moving to the left node then goes to the right because that would put him back on the path which he wasn’t on because he moves independently , you could try populating the map with more path nodes, if thoes nodes you have set up are special locations that a unit must stand you could set something up that would cause a a path to go to thoes specific locations. instead of having them as the only locations


#11

The problem is that there IS an option that tells him to start the path at the close point on the path AND that point doesn`t have to by one point, it can be any position along a link. If it worked correctly, then everything would be perfect, but it clearly doesn’t start at the right place. My AI doesn’t have to be preceasly on the path, just close enough. Bottom point, it 's a bug that should be fix.


#12

Hi

Just to make sure. Are all your point graph nodes placed on (roughly) the same z coordinate? Or do they vary a lot?


#13

They are all exactly at z = 0


#14

Hi

I could not replicate the issue anymore after I removed your PathNeedsFix method which seems to remove nodes from the path for unknown reasons sometimes.


#15

I will try it on my side to


#16

Indeed, it was my code the problem. I hadded this code because I had an other problem with the path, but when I removed my code, I guess this problem was fixed during the last update, since it doesn’t look like it’s there anymore.

Thanks alot for your help! :slight_smile:


#17

I have unfortunate news. I found an other problem and this time, my code isn’t the cause of it! I’m not sure how to explain it, but the wrong path is generated. I added two picture.

The first one shows the path being correctly calculated. The second picture is what happen when I just move a little my character (the wrong path).

Clearly, the path generated is not good and I made sure to check without my code that changes the path (it doesn’t apply in this situation anyway).

The link to my git up (see previews replies) is still working. To reproduce the bug, select “Jumping Paltformer AI” in the Hierarchy tab and untick “Platformer Movement” (to prevent him from moving). Then, just move around the AI with the move tool. The project is in Unity 2018.2.8f1.

I also did a video (bug starts around 24 secondes):

Hope it helps


#18

you’re recalculating the path while hes moving and not waiting for his path to finish before starting a new one.
and ill reiterate you’re using the system backwards, you’re using nodes like waypoints, the path is suppose to find the nodes between waypoints.


#19

I have no choice to recalculate the path (4 time by seconds) since my AI is trying to follow a character (the character is moving). Plus, in this case, my path DOES have time to finish before recalculating it and it doesn’t have anything to do with this issue. I say this for two reasons:

  1. I get a log message telling me that the Path was completed without any problems

  2. Just to be sure, I tweaked my code so that it will only calculate ONE path at the start (in case the confirmation logs were wrong somehow). I made sure that my AI is at the same spot has the one showed in the video and that he isn’t moving AT ALL. The wrong path still get generated and since I only genereted the path ONCE, I think you can agree that the update rate AND the movement has nothing to do with this issue.

Also, I’m not using the nodes like waypoints. My AI is using the path generated the figure out how to move to reach it’s destination (actually, it’s figuring out it’s controls, because controls and movement are completly seperated, but that’s not what is important here).

Finally, even if I was using the system backwards, that is not what this issue is about. I get that you’re trying to help me, but what I need help with is the path not being correctly generated in this specific case scenario.

Again, thanks for your help, but I think you’re not looking in the right place.


#20

you want it to use the top path. but the path from the ledge is shorter than the path from the left of the ledge.
you are creating a new path before the fox has had time to reach the next platform, its taking the shorter of the two paths, although both paths look equal distance. its just prefers one of the two equal distance paths over the other…


#21

You don’t seem to understand the issue. Regardless of if that is actually the shortest path, the path doesn’t even start at the correct position! The option I selected for the Seeker script is that it should start it the closest point along the clossest line (“Node Connection” for “Start Point Snapping”). Clearly, it doesn’t do that. THAT is the issue.

Plus, if you look at, the video, the wrong path generated clearly isn’t the shortest path. It already was going along the correct path and it was getting closer and closer, and it suddently generated a path that would required some back tracking, therefore making it logically longer then the correct path.


#22

I think I kind of found what is going on. The reason why the path isn’t correct is simply because I placed my point in a very unique way and I guess that when the point graph was tested, the way I put my point didn’t fell in the set of case they tested. So basically, my situation is a really extreme “edge case”, that the system just doesn’t handle well.

I decided to remove one of the point and it fixed the issue, but I still think that this issue should REALLY be looked into. Since I’m working on a prototype, it isn’t that much of an issue for me and it actually helped me reflect on my AI and realise that I better just make it better at handelling jump and more smart. I originally hadded the extra point to prevent him from falling immediatly of the edge, but, now that I think of it, it really wasn’t the smartest solution.

I really hope that this issue will be fix, but, for now, just don’t put the points in such a way and it should be fine.
Thanks for all the help! :slight_smile:


#23

Hi

Sorry for the late answer. I have been sick for a while.

Ah, so the reason it does not work in your case is because the pathfinding queries will always, without exception, find the closest node to the start and end points. During post-processing it may modify the start and end point of the path to lie on the connections to the start and end nodes, however when searching it will always find the closest node, not the closest point along a connection to a node.

It is possible I suppose to change this behavior, in the PointGenerator.cs script in the GetNearestInternal method you will have to add distance checks not just to the node’s center, but to the closest points along its connections. I can help you add that if you want.