Wednesday, October 20, 2010

Droids - Spawn Points with Gizmos

Enlisting the Unity editor to help create content is a powerful feature. In my case I wanted to create some spawn points for some work stations as part of my droid factory. The work stations are spawned in random locations. The possible locations are pre-determined (my spawn points). One thing I didn't want to do is fidget with these points to get the location just right. I wanted something that lets me spend as much time as possible in the editor.

My solution was to draw an approximation of the model using the editor. To top it off I pulled this information from the prefab itself. This code also includes finding a prefab and using its data without there being an instance of it. I also had to filter out game objects that weren't prefabs (otherwise the editor will draw those).

Here's the code:

This is how it looks:
Yellow spawn points indicate where objects can appear

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.