ALL THE RANDOM GENERATION!!! I hope you guys like random generation because that's a lot of what you get here, anyway today we're talking about some percentage based random generation.
In my newest game project Purrpulsion, we wanted to have our players flying through the air and past objects that were randomly being spawned. For this I needed to create prefabs, yet again, of everything that I was going to spawn. Then I would find a random number between 1-100 (I could have done this from 0-1 but decided against it) and then wrote code to spawn fuel if the number was between 1-20 or a bomb if it was between 21-100. This gives us a percentage based spawning system where 20% of the time it will be fuel and 80% of the time it will be a bomb.
As for where the object was being spawned, I wanted them to spawn as the same z point but different x,y points all within the view of the camera (or the maneuverability of the ships). To do this I used a method in Unity called .insideUnitCircle() which takes a radius and position and determines a random point between the position and the radius. This allow for sporadic placing of the objects and created a fun environment.
If you have any questions leave them down below and I'll get back to you. I love random generation and how it makes the game a different experience every time.
For more information on my games and what I've done check out my portfolio website:
http://brendandev.com/
You can also check out my facebook page and twitter for information on my videos and game development work:
https://www.facebook.com/pages/Frosty...
/ brendangamer