public static int[,] getCollisionArray(int[,,]mapData, IntVector3 direction) { /* where direction is a unit vector, pointing in the direction mapData is travelling the direction vector decides what the collision plane will be. for example the collision plane of a moving car is vertical, like the surface of a brick wall, in front of the car. the returned collisionArray is the heights of the nearest voxel lining up to each (x,y) of that plane. */ //Debug.Log ("getCollisionArray " + direction.i + " " + direction.j + " " + direction.k); if (! direction.isOrthogonalUnitVector ()) Debug.Log ("warning: getCollisionArray didn't get a unit vector."); IntVector2 arraySize = getCollisionArraySize (mapData, direction); int [,] collisionArray = new int [arraySize.x, arraySize.y]; for (int xOffset=0; xOffset<arraySize.x; xOffset++) { for (int yOffset=0; yOffset<arraySize.y; yOffset++) { int dist = getClosestVoxelDistance (mapData, xOffset, yOffset, direction); collisionArray [xOffset, yOffset] = dist; if (dist != -1) { //Debug.Log ("xoffset: " + xOffset + " yoffset: " + yOffset + " dist: " + dist); } } } return collisionArray; }