Răsfoiți Sursa

Merge pull request #258 from 0ttoman/my-branch

checking array length beforehand
Nathan Lovato 7 ani în urmă
părinte
comite
334426403c
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      2d/navigation_astar/character.gd

+ 1 - 1
2d/navigation_astar/character.gd

@@ -18,7 +18,7 @@ func _ready():
 func _change_state(new_state):
 	if new_state == FOLLOW:
 		path = get_parent().get_node('TileMap').get_path(position, target_position)
-		if not path:
+		if not path or len(path) == 1:
 			_change_state(IDLE)
 			return
 		# The index 0 is the starting cell