Closed MorphicDreamer closed 3 years ago
It looks like a bug in your code : index is incremented before adding a new tile, so your indexing is not zero based. Moving index++
after adding the tile may fix your issue. Node indexing should always be zero based (starting at zero).
Thanks so much @mgsx-dev. It worked! :)
Please ensure you have given all the following requested information in your report.
Issue details
Please provide the details of your issue Gdx.ai is giving a cryptic error saying that "index 81 is out of bounds for length 81" the map that I am using Gdx.ai is a 9X9 isometric map not including index 0 e.g. tiles[8][8] is the top of the map
Reproduction steps/code
Please provide the steps to reproduce this issue, or even better, a SSCCE that reproduces your issue. I used someones implementation of code to find neighboring tiles connecttiles(tiles(tiles[x][y]), tiles[x][y-1]) and the code works for most examples but it fails on any tiles you move from tiles[7][7]
Version of gdx-ai and/or relevant dependencies
i am using libgdx version 1.100 and Gdx.ai 1.8.2
Stacktrace
Exception in thread "LWJGL Application" java.lang.ArrayIndexOutOfBoundsException: Index 81 out of bounds for length 81 at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.getNodeRecord(IndexedAStarPathFinder.java:279) at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.visitChildren(IndexedAStarPathFinder.java:204) at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.search(IndexedAStarPathFinder.java:117) at com.badlogic.gdx.ai.pfa.indexed.IndexedAStarPathFinder.searchNodePath(IndexedAStarPathFinder.java:94) at com.mygdx.game.map.map.findpath(map.kt:118) at com.mygdx.game.map.map.tileinfo(map.kt:101) at com.mygdx.game.Player.Units.baseunit.mouse(baseunit.kt:75) at com.mygdx.game.Player.Units.baseunit.render(baseunit.kt:38) at com.mygdx.game.Screens.gameScreen.render(gameScreen.kt:53) at com.badlogic.gdx.Game.render(Game.java:46) at com.mygdx.game.MyGdxGame.render(MyGdxGame.kt:29) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:232) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)