Advertisement
Kermer

Custom AStar

Apr 29th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. class CustomAStar:
  2.     extends AStar
  3.     var high_cost_points = []
  4.     func _estimate_cost( id_a, id_b ):
  5.         if (id_a in high_cost_points or id_b in high_cost_points):
  6.             return get_point_pos(id_a).distance_to(get_point_pos(id_b)) * 2
  7.         # else
  8.         return get_point_pos(id_a).distance_to(get_point_pos(id_b))
  9.  
  10. func _ready():
  11.     var astar = CustomAStar.new()
  12.     # [ Add points ]
  13.     astar.high_cost_points = [ 3, 5, 47, etc. ] # IDs of points
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement