Astar parent, getpath

大兔子大兔子 提交于 2019-12-11 14:45:31

问题


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



来源:https://stackoverflow.com/questions/46565789/astar-parent-getpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!