Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | kender99 |
I am trying to have player walk towards a destination defined by the click of the mouse.
But although the coordinates of the input even and the points seem to be right
The path followed is all wrong.
func _unhandled_input(event):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed:
path = $Navigation2D.get_simple_path($Player.position, event.position)
$Player.path = path
$Line2D.points = path
print(path.size(), ' Path:',path, ' Player:', $Player.position, ' Target:', event.position)
update() # so line and circles get drawn
func _draw():
for p in path:
draw_circle(p, 5, Color(200, 200, 200))
Very minimal demo here
Any help appreciated!