i want to create an index array to hold various other arrays in java script.
my goal is to use it to help sort through paths with my pathfinding AI.
i’m getting so many different errors as i’m going along i was hoping that someone could show me a working version of code where this is accomplished so i can use it as reference. i will then rebuild it from scratch asw my current code is pretty much beyond repair after all my attempts to fix it.
if possible could you also show an example of referencing an array inside the index array. as that is where my biggest issue seems to have been.
You mean something like this?
function Start () {
var tFauxMatrix = new Array();
tFauxMatrix.Push(new Array("a", "b", "c"));
tFauxMatrix.Push(new Array("x", "y", "z"));
Debug.Log(tFauxMatrix[0][2]);
Debug.Log(tFauxMatrix[1][1]);
}
The above would result in “c” then “y” being output. I’m not sure quite where you’re stuck so pardon the basic example if you’re past that level. In the long run you’ll really want to work with built-in arrays if at all possible. They come with some limitations but can be much faster and you’ll need that speed in any pathfinding routines.
Offer extra guidance if I’ve missed the mark.