Browse Source

checking array length beforehand

0ttoman 7 years ago
parent
commit
d09cc6af8b
1 changed files with 1 additions and 1 deletions
  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