Astar parent, getpath

2019-08-29 01:50发布

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;
}

enter image description here

标签: a-star
1条回答
男人必须洒脱
2楼-- · 2019-08-29 02:28

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 ...

查看更多
登录 后发表回答