- Home /
Use abstract class for GetComponent?
Sort of a quick question. I have a class called WeaponManager() that manages a bunch of weapons, and a class called BaseShip() that other kinds of ships will extend/implement. WeaponManager() and a derivation of BaseShip() will both be attached to a GameObject to define a ship.
Now in WeaponManager(), I have:
myShip = GetComponent<BaseShip>();
I discovered BaseShip can't be an Interface because then GetComponent won't grab it. I thought of making it an abstract class, but there's nothing in common among different ships. There are a bunch of fields that every derivation must have, but in all the C# examples I've seen on the web I haven't seen any uninitialized fields declared in abstract classes.
So should I just make a regular class? In my case it doesn't make any sense to instantiate a Ship class. What is the best choice?