Kermer icon

Custom AStar

Kermer | PRO | 04/29/17 09:39:19 AM UTC | 0 ⭐ | 222 👁️ | Never ⏰ | []
Python |

420 B

|

None

|

0 👍

/

0 👎

class CustomAStar:
    extends AStar
    var high_cost_points = []
    func _estimate_cost( id_a, id_b ):
        if (id_a in high_cost_points or id_b in high_cost_points):
            return get_point_pos(id_a).distance_to(get_point_pos(id_b)) * 2
        # else
        return get_point_pos(id_a).distance_to(get_point_pos(id_b))
 
func _ready():
    var astar = CustomAStar.new()
    # [ Add points ]
    astar.high_cost_points = [ 3, 5, 47, etc. ] # IDs of points

Comments