Mixing spawn objects ?

Updated on January 15, 2017 in Answers
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on January 15, 2017

This script spawn enemies. It gives only one type of enemy but not mixing them. How to mix them ?

 public GameObject[] enemys; // 5 types
 void Update ()
 {
 Vector3 e_spot = transform.position;
 if (Input.GetKeyDown(KeyCode.X))
 {
 int enemy_types = Random.Range(0,6);
 for(int i = 0; i <= enemy_types; i++)
 {
 Instantiate(enemys[enemy_types], e_spot, Quaternion.identity);
 }
 }
 } 
 

  • Liked by
Reply
0 on January 15, 2017

You can have an array of enemies and then use Random.Ramge

  • Liked by
Reply
Cancel
3 on January 15, 2017

I think I did that before. All what I need is mix enemy objects.

Wise
on January 15, 2017

Well, and did it work?

on January 15, 2017

oh man, I don’t think so. Can I add any thing to script that mix enemy objects ? or I have to get back to array ?

Wise
on January 15, 2017

What?

Show more replies
  • Liked by
Reply
Cancel