so, i am trying to add instatiated gameobjects position x,y,z to an array, so i can get a random from the list to generate a “Ore” or well, it doesent really matter what, just so i can get a random from the list and get that objects position.
But it is really bugging me, this is how far ive comen yet
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TerrainPerlinNoise : MonoBehaviour {
int chunkheightmapWidth = 100;
int chunkheightmapHeight = 100;
public float EpicGenerator;
private Quaternion rot;
public GameObject cubePrefab;
public GameObject Cubes = null;
public Vector3[,,] CubeCount = new Vector3[100,20,100];
public int _Xpos;
public int _Ypos;
public int _Zpos;
OreGen oregen;
int posI = 0;
int posK = 0;
public float Tiling = 10.0f;
void Start()
{
EpicGenerator = Random.Range(0.8f, 1.9f);
rot.eulerAngles = new Vector3(0,0,0);
GenerateHeights(Tiling);
}
void Update()
{
if(Input.GetKeyDown(KeyCode.I)){
Debug.Log(Random.Range(0,(CubeCount.Length - 1)));
oregen.generate(CubeCount[3,3,3 ]);
}
}
public void GenerateHeights(float tileSize)
{
float[,] heights = new float[chunkheightmapWidth, chunkheightmapHeight];
for (int i = posI; i < chunkheightmapWidth; i++)
{
for (int k = posK; k < chunkheightmapHeight; k++)
{
heights[i, k] = Mathf.PerlinNoise(((float)i / (float)chunkheightmapWidth) * tileSize, ((float)k / (float)chunkheightmapHeight) * tileSize)/EpicGenerator;
Cubes = Instantiate(cubePrefab, new Vector3(i, heights[i, k], k), Quaternion.identity) as GameObject;
Cubes.name ="Cube place: " + i + heights[i, k] + k;
CubeCount[_Xpos, _Ypos, _Zpos] = (i + heights[i, k] + k);
}
}
}
}
and i literraly have no idea wtf is going on, i give them new names, and i add them to cubecount, but when i ask to debug log CubeCount, it gives me ONE Integer, with 6 digits in it.