2017-10-04 83 views
0

有我的astar算法,但我不知道如何獲得父母,並從目的地獲得快速路線。Astar父母,getpath

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

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

enter image description here

+0

圖像帶到在線。代碼格式改進。 – Assafs

回答

0

你必須設置 「當前」 作爲父母相鄰節點。然後,如果目標被發現,你跟隨父項的路徑,這就是路徑

編輯:另外我不能看到一個「成本」的實施......