I am trying to make simple terrain generation in my Minecraft clone. Whenever I try to run the script, it places ALL the instantiated objects at the position 0, 0, 0. Here is my C# code for terrain generation:
using UnityEngine;
using System.Collections;
public class TerrainGen : MonoBehaviour {
public int radius;
public int maxHeight;
public GameObject block;
void Start ()
{
for (float x = 0; x < radius; x+=1)
{
for (float z = 0; z < radius; z+=1)
{
float y = Random.Range(1, maxHeight);
Vector3 v = new Vector3(x, y, z);
GameObject newBlock = Instantiate(block, v, Quaternion.identity) as GameObject;
Debug.Log("Block's Position: " + newBlock.transform.position + " | Wanted Position: " + v);
}
}
}
void Update ()
{
}