using UnityEngine;
using System.Collections;
public class Generation : MonoBehaviour
{
public float X = 0;
public float Y = 0;
public float Z = 0;
public GameObject Grass;
public GameObject Stone;
public GameObject Bedrock;
public int BlockNumber = 0;
public int Rand;
public float RandY;
public int LastY = 0;
public int Last;
void Start ()
{
GenerateChunk ();
RandY = Y + Rand;
LastY = 0;
}
void GenerateStone()
{
Instantiate (Stone, new Vector3 (X, RandY, Z), Quaternion.identity);
}
void GenerateGrass()
{
Instantiate (Grass, new Vector3 (X, RandY, Z), Quaternion.identity);
}
void GenerateBedrock()
{
Instantiate (Bedrock, new Vector3 (X, RandY, Z), Quaternion.identity);
}
void Update ()
{
Rand = Random.Range (-1, 2);
LastY = Last + Rand;
print (LastY);
}
void GenerateChunk()
{
for (Z = Z; Z <= 16; Z++)
{
for (X = 0; X <= 16; X++)
{
GenerateColumn();
}
}
}
void GenerateColumn()
{
BlockNumber = 0;
for (RandY = LastY + Y; RandY >= -50; RandY--)
{
if(BlockNumber < 4)
{
GenerateGrass();
}
else if(RandY == -50)
{
GenerateBedrock();
}
else
{
GenerateStone();
}
BlockNumber++;
}
}
}
I want it bt be possible for LastY to be more than 1 or less than -1;