Quantcast
Channel: Answers by "Flynn"
Viewing all articles
Browse latest Browse all 59

Answer by Flynn

$
0
0
Hello, there! First of all, I suggest that instead of using boolean signals to tell SpawnEnemy to spawn, that you instead go a little more directly: ###EnemySpawn.js: #pragma strict var prefab : Rigidbody; public function SpawnEnemy()//Create a public function we can call later { print("Enemy has spawned"); Instantiate(prefab,transform.position,transform.rotation); } ###Spawner.js public var eSpawn : EnemySpawn; #pragma strict function OnTriggerEnter(collision : Collider) { if(collision.CompareTag("Player")) { print("YAY"); eSpawn.SpawnEnemy();//Call the function we defined earlier } } But besides all of that, to ***actually answer your question***, it seems that it only spawns one, because you only ever tell it to! Does your prefab contain more than one object in it? If not, I suggest doing this: ###EnemySpawn.js #pragma strict var prefab : Rigidbody; public function SpawnEnemy() { for (int i = 0; i < 3; i++)//Create a for loop that repeats its self 3 times { print("Enemy has spawned"); Instantiate(prefab,transform.position,transform.rotation); } }

Viewing all articles
Browse latest Browse all 59

Trending Articles



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