Nothing bad about empty game objects from a performance perspective (no draw calls since it doesn't have a renderer and very low mem overhead, plus you have to store it somehow). There are lots of ways to skin this cat and empty objects is one of them. Create a prefab for each of your ship types with empty objects for the locations. Then reference them in the ship script.
public transform weaponLocationStarboard;
You could also add a script to your "empty" object so that you can add info to your weapon locations.
When I have a lot of objects subbed to something I'll usually have a class/script I attach so I can do something like:
private MyThing[] myThings;
void Start ()
{
//get ALL the things
myThings = this.GetComponentsInChildren().OrderBy(n => n.ID).ToArray ();
}
In some situations it's a lot easier (e.g. 20 slots you need ordered from id 1-20).
↧