Quantcast
Viewing latest article 15
Browse Latest Browse All 125

Random Generation problem GameObject

I have a problem how to set a Random object in a polygon without placing it on another object in that polygon Code is: public float XSize = 8.7f; public float ZSize = 8.7f; public GameObject foodPrefab; public Vector3 curPos; public GameObject curFood; void AddNewFood() { RandomPos(); curFood = GameObject.Instantiate(foodPrefab, curPos, Quaternion.identity) as GameObject; } void RandomPos() { curPos = new Vector3(Random.Range(XSize * -1, XSize), 0.25f, Random.Range(ZSize * -1, ZSize)); } void Update() { if (!curFood) { AddNewFood(); } else { return; } } }

Viewing latest article 15
Browse Latest Browse All 125

Trending Articles



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