Astar parent, getpath

2019-08-29 02:21发布

问题:

there is my astar algorithm, But I don't know how to get parent and get a quick route from the Destination.

Node script methods
getPos()  (Vector2)
Parent  (Node)

Node n = ?.Parent;
while(n != null)
{
    path.add(n.getPos());
    n = n.Parent;
}

回答1:

You have to set "current" as parent to the adjacent nodes. Then if the destination is found, you follow the path of the parent entries, this is the path

EDIT: Also i can´t see a "cost" implementation ...



标签: a-star