So i went ahead and whizzed up a basic random world generator that spawns random chunks next to each other. It works by sending out empty gameObjects to the side and instantiating basic chunks at the postition of these transforms. The problem is that it only seems to be generating of to the left, not the right. ALSO: the chunks seem to be instantiated of to the right but nothing is appearing. Heres the editor:
Heres my code:
using UnityEngine;
using System.Collections;
public class WorldGeneMan : MonoBehaviour {
public GameObject lg;
public GameObject rg;
public GameObject chunk_top_1;
public GameObject chunk_top_2;
public GameObject chunk_top_3;
public Random ran;
public int ran1;
public int ran2;
public GameObject sChuckr;
public GameObject sChuckl;
// Use this for initialization
void Start () {
Instantiate(chunk_top_3, transform.position, transform.rotation);
//Right gen
for (int i = 0; i < 5; i++)
{
ran1 = Random.Range(1, 4);
rg.transform.position = new Vector3(rg.transform.position.x + 8, rg.transform.position.y, rg.transform.position.z);
if (ran1 == 1)
{
sChuckr = chunk_top_1;
}
else if (ran1 == 2)
{
sChuckr = chunk_top_2;
}
else if (ran1 == 3)
{
sChuckr = chunk_top_3;
}
Instantiate(sChuckr, rg.transform.position, rg.transform.rotation);
}
//left gen
for (int i = 0; i < 5; i++)
{
ran2 = Random.Range(1, 4);
lg.transform.position = new Vector3(lg.transform.position.x - 8, lg.transform.position.y, lg.transform.position.z);
if (ran2 == 1)
{
sChuckl = chunk_top_1;
}
else if (ran2 == 2)
{
sChuckl = chunk_top_2;
}
else if (ran2 == 3)
{
sChuckl = chunk_top_3;
}
Instantiate(sChuckl, lg.transform.position, lg.transform.rotation);
}
}
// Update is called once per frame
void Update () {
}
}
Plzz help