1

I am a complete noob when it comes to coding in unity . I have a couple of different enemies that are scriptable objects and when I start a battle I would like to load a random one of those enemies. Can anyone please help I cant figure out how to do it.

1 Answers1

0

It depends on what you have. Are you loading Scriptable Objects from the Resources folder? If you are, you may use Object[] enemies = Resources.LoadAll("Enemies", typeof(Enemy)). This code will load everything of a type "Enemy" from a folder "Resources/Enemies/". Then you can get random numbers from 0 to enemies.Length and get an object from the array using the number as an index

Dasic
  • 29
  • 5