forked from uheartbeast/astar-tilemap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorld.gd
More file actions
19 lines (15 loc) · 643 Bytes
/
World.gd
File metadata and controls
19 lines (15 loc) · 643 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
extends Node2D
onready var board = $Board
onready var astarDebug = $AstarDebug
onready var player = $Board/Player
onready var line = $Line
func _input(event):
if event.is_action_pressed("mouse_left"):
var target_cell = (event.position / board.cell_size).floor() * board.cell_size
var path_points = board.get_astar_path_avoiding_obstacles(player.global_position, target_cell)
line.position = board.cell_size/2 # Use offset to move line to center of tiles
line.points = path_points
if event.is_action_pressed("mouse_right"):
line.points = []
if event.is_action_pressed("ui_accept"):
astarDebug.visible = !astarDebug.visible