A* Pathfinding Project

Different results


#1

Hi there,

I have a problem maybe someone can figure it out.

I have unity as client and server in javascript and both using a* same formula and diagonal however sometimes the client moves in different coordonates compared to the one received from server as path. What could be the logic in this? On sv is creating a matrix of 10x10 grid so it is 2d and u ity shows that as 3d moving to one grid to another.

And in case there is no solution to my issue, is there anyway to pass the full path nodes directly in unity to the pathfinder?

Thank you everyone


#2

I’m not exactly sure how but my guess would be the server would need to use the postProcessPath callback and then sync the found path with the client. This way the exact nodes the seeker will path across are the same.

Seeker seeker;
public void Start(){
    seeker = this.GetComponent<Seeker>();
    seeker.postProcessPath = OnPathCalculated;
}

public void OnPathCalculated(Path p){
    //sync the found path with the client
    //p is the exact path that was found including all the graph nodes
}

public void OnPathComplete(Path p){
    //seeker reached the end of the path
}

public void FindPath(Vector3 positionToPathTo){
    //this would only run on the server
    seeker.StartPath(this.transform.position, positionToPathTo, OnPathComplete);
}

public void StartPathFromPath(Path p){
    //this would be called somehow by the client after it received the path.
    seeker.StartPath(p, OnPathComplete);
}

Not sure how to create a path from a List of GraphNodes or how you’d sync the path object but hopefully this helps.


#3

Ok thanks will give it a try, i still dont know why i get different path as it should im theory give same result, if naything know anything about nodejs and unity i can pay to get a fix


#4

if you’re using any of the default movement systems you can use the function SetPath(Path p) https://arongranberg.com/astar/docs/aibase.html#SetPath


#5

Hi

You mention nodejs a lot. It sounds like you are using a pathfinding library for nodejs and is expecting this library to generate the exact same path? Is that correct?
One potential issue is that for a given start and end point there are multiple equally long paths and different pathfinding libraries differ in what kind of tie breaking they use.