I have a turret which is capable of instantiating objects which are either a CannonShell or HomingMissile. Both of these derive from a base class called Projectile.
They are derived from the same base class because I would like to use the same turrets to fire either one depending on how it is set up in the Editor.
The problem is, I want to be able to set a HomingMissile’s target when it is instantiated, but I do not want to have to set a target for a CannonShell, since it will have no use for it, and I plan to devise many more weapons without having to make Projectile support dozens of features, only one of which is used in each one, or to have to break the Launcher every time I come up with a new weapon.
I would ideally like to be able to script
if ( /* the instantiated object has a member called "target" */) {
instantiatedObject.target = myTarget;
}