|
Right now I'm developing a game that requires enemies to spawn at specific times. To simplify this process, I have sort of a "spawning manifest", which contains 3 different public arrays. The first lets me choose a prefab, the second lets me pick what time each enemy is spawned, and the third tells it where to spawn. However, enemies of all different types will need to be spawned (and they have numerous variables, such as firing rate, movement speed, etc.). Will I need to make a prefab of every tiny variation, or is there some way to access (in the editor) a GameObject's components/values while it is displayed inside of an array? For instance, in the Inspector I unfold the "Enemies" array, add one to the list, and I can see all of its editable values much like if I selected the prefab directly? If not, this doesn't bode well and I'll have to scrap my entire spawning system, and unfortunately I don't know what else to do in its stead except place every enemy by hand.
(comments are locked)
|
|
The easiest way to do this is to create a custom inspector. you should start with: http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html here is an example of building custom arrays: http://answers.unity3d.com/questions/26207/how-can-i-recreate-the-array-inspector-element-for.html what you would need to do is add some stuff to expand each array element in a similar manner. I've been scared of trying to extend the editor so far. :P It seems fairly complicated. I'll consider it though.
Aug 16 '11 at 06:29 AM
Jason B
(comments are locked)
|
|
Sounds like your structure dependencies are backwards, since you don't want the variables in the prefab GameObject, yet you have them there. I would suggest that you move those variables you mention to an EnemyData class that is just a structure of the variables. You then have a single array of these. When an object is spawned, the prefab is instantiated, and a Yeah, I'm still trying to learn as I go and I'm finding more and more that the less I plan, the more stumbling blocks I hit on the way, so I'm trying to make everything as easily modifiable as possible. I thought I was being proactive for my spawner but it clearly has its shortcomings. I suppose I could do what you say, and then use SendMessage to the instantiated objects to inform their statistics (I have to use something general because all the different enemy types are so different that they use different AI scripts, though I could give them all similarly-named functions so they can receive generic SendMessage orders). Not sure if I'm muddling your suggestion though.
Aug 16 '11 at 06:27 AM
Jason B
(comments are locked)
|
