ramdom intantiate

hi, im new to unity , ill like to implement a code that intantiate a random enemy from a dificulty that will scale on time at a ramdom position.

OK, what Have you tried so far? I doubt anyone will just write this for you. Make an attempt, then when/if you have errors or things don’t work like you expect them to, post your code and your issues!

Also, this is an awesome place to get started, and Unity is offering it for free during the Covid Pandemic.

You have to break complex problems down into smaller problems which you tackle separately. Just off the top of my head.

  1. Create enemy prefabs
  2. Put all enemy prefabs in a list
  3. Select a random entry from the enemy prefabs list to instantiate
  4. How do you want to implement enemy difficulty?
  5. How do you want to scale difficulty over time? Do you make enemies stronger, or do you choose from a list of more difficult enemies?
  6. How do you want to select a random position? Are these a list of spawn points you choose at random, or do you just choose a random x/z coordinate and spawn in there?

Look up Random.Range to give you a start on the random number part.

2 Likes