Using class variables
What's the proper way to use class variables and actually create objects from the variable?
My specific problem appears to be that I'm trying to create an object in a constructor; NewObject() gives the error "NewObject can't be used to create default subobjects (inside of UObject derived class constructor) as it produces inconsistent object names. Use ObjectInitializer.CreateDefaultSuobject<> instead.". However, CreateDefaultSuobject is not an option because the class is passed in through the template, meaning it must be a specific type, and I can't use a class for dynamic object creation.
What I'm trying to accomplish with this is streamlining the mesh components. Right now I have mesh component declared in the abstract class Weapon, however since it's abstract, Weapon itself will not have a mesh. What I want to do is basically, in Weapon, "Create a mesh specified by a variable, attach to root, set properties on that mesh". It looks like if I can't do this, I would need to copy/paste this code into every single subclass that I make.
I'm still new to this so it's possible that my approach is completely off. Any assistance would be appreciated. Thanks.
asked Mar 26 '15 at 08:45 PM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here