private void find_tile(float[] x, float[] z, int nRigidBodies) {

		int serial[] = new int[nRigidBodies];
		for (int i = 0; i < nRigidBodies; i++) {
			// Check for the loaction of each tile to find which one should be
			// switched on...Extend it to include values from all tiles!
			// currently only supports 4
			for (int j = 0; j < numTiles; j++) {
				if ((x[i] > tileCoords[j][0]) 
						&& (x[i] < tileCoords[j][1])
						&& (z[i] > tileCoords[j][2])
						&& (z[i] < tileCoords[j][3])) {
					serial[i] = j+1;
					break;
				}
			}

			/*
			 * if ((x[i] > tileCoords[0][0]) && (x[i] < tileCoords[0][1]) &&
			 * (z[i] > tileCoords[0][2]) && (z[i] < tileCoords[0][3])) serial[i]
			 * = 1; else if ((x[i] > tileCoords[1][0]) && (x[i] <
			 * tileCoords[1][1]) && (z[i] > tileCoords[1][2]) && (z[i] <
			 * tileCoords[1][3])) serial[i] = 2; else if ((x[i] >
			 * tileCoords[2][0]) && (x[i] < tileCoords[2][1]) && (z[i] <
			 * tileCoords[2][2]) && (z[i] > tileCoords[2][3])) serial[i] = 3;
			 * else if ((x[i] > tileCoords[3][0]) && (x[i] < tileCoords[3][1])
			 * && (z[i] < tileCoords[3][2]) && (z[i] > tileCoords[3][3]))
			 * serial[i] = 4;
			 */
		}

		// only send messages to the tiles if the state of any tiles have
		// changed since the last time otherwise skip this step.
		if (!Arrays.equals(SerialNo, serial)) {
			SerialNo = serial.clone();
			send_msg();
			System.out.println("CUrrent tile is" + SerialNo);
		}

	}