Quantcast
Channel: Questions in topic: "random spawn"
Viewing all articles
Browse latest Browse all 125

Ecosystem generator script generating everything in the same place

$
0
0
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); } } }

Viewing all articles
Browse latest Browse all 125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>