Hello, it seems that my ecosystem generator script is "randomly" spawning all of the game objects in about three different places, even though the coordinates are "randomized" every time an object is spawned.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EcoGeneraterScript : MonoBehaviour {
public GameObject Tree;
public GameObject Mob;
public int NumberOfTree;
public int NumberOfMob;
private float Randomx;
private float Randomz;
void Start () {
Random.InitState (44);
Randomx = Random.Range (50, 950);
Randomz = Random.Range (50, 950);
}
void Update () {
if (NumberOfTree > 0) {
Tree = Instantiate (Tree, new Vector3 (Randomx, 0, Randomz), Quaternion.identity);
NumberOfTree += -1;
Randomx = Random.Range (50, 950);
Randomz = Random.Range (50, 950);
}
if (NumberOfMob > 0) {
Tree = Instantiate (Tree, new Vector3 (Randomx, 0, Randomz), Quaternion.identity);
NumberOfMob += -1;
Randomx = Random.Range (50, 950);
Randomz = Random.Range (50, 950);
}
}
}
↧