Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How To Select Random Enemy From Array

$
0
0
How would I select a random enemy from an array index. So far I have made this script that spawns all enemies from the array, instead of picking one random enemy from the array. I can post more code if needed. Code: for(int i = 0; i < EnemyPrefab.GetLength(0); i++) { Vector3 offset = Random.onUnitSphere; // Setting a value offset.z = 0; // Setting a value offset = offset.normalized * SpawnDistance; // Instantiating the Gameobject GameObject go = (GameObject) Instantiate(EnemyPrefab[i], transform.position = offset, Quaternion.identity); }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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