I'm building a top down game wherein I wish the environment around the player to be generated randomly. Essentially I wish objects to be spawned out of the view in a radius around the player and the be destroyed when they are a certain distance away. At this stage it can just be a single object.
Before I attempted to build this myself I wanted to ask a few more experienced Unity users how they would tackle this question?
I was thinking of perhaps using a Bounds where the area between the extents and size was the spawnable area, however I'm at a loss on how I would calculate points only in that area.
Thanks, any help is much appreciated, ~Hawk
asked Jan 21 '10 at 04:13 AM
You can use something like this:
It will generate a random position but discard it if the position is too close to the player.
You can use the same principle when destroying objects too far away:
Run this code every second or so.
answered Jan 21 '10 at 06:44 AM