- Home /
Question by
twotostudio · Sep 02, 2020 at 12:24 AM ·
randomspawning
creating random objects at specific points
I want to randomly spawn different objects at certain points. However, I get an error in the instantiate part. How should I do it?
ekran-alıntısı.png
(25.7 kB)
ekran-alıntısı.png
(25.7 kB)
Comment
Best Answer
Answer by imM4TT · Sep 02, 2020 at 01:24 AM
You are almost fine with this script, you may have already fixed it:
- myobjects is an array, you can't pass it as Instantiate() parameter, you need to pass a single gameobject such as you did for spawnPos.
- spawnPos is already an array of Transform
Instantiate(myobjects[0], spawnPos[spawn].position, Quaternion.identity);
Your answer
![](https://koobas.hobune.stream/wayback/20220613011031im_/https://answers.unity.com/themes/thub/images/avi.jpg)