I implemented a state system. Parent (abstract) base class is in C++ (child of UObject), actual classes are blueprints. Blueprints aren’t objects though, so I have to instantiate each class once and save them into a Map<ControlInputStateBase “Class Reference”, ControlInputStateBase>. I do this in the ThirdPersonController’s Constructor.
I have five states now and my Constructor is turning into spaghetti, so I want to simplify things by converting this into C++. My problem is that I am unsure how to declare the TMap because I do not know what the C++ equivalent is to a “Class Reference” type.
But it gives me five errors, e.g. ‘UControlInputStateBase’: undeclared identifier" and “UControlInputStateBase is not a valid identifier.” I also tried using an enum, but I got another error “TDefaultMapHashableKeyFuncs: unspecialized class template can’t be used as a template argument for template parameter ‘KeyFuncs’” so enums are out, too, I suppose.
Does anyone know how I can fix my current problem? Thank you in advance!
To be perfectly honest, if you don’t understand core concepts like these, then there is no point in converting to C++. You’ll just end up with more mess. You can learn the basics of C++ in a few days.
Well I know C++. I’m not asking to make a reference to an object, that’s a piece of cake and I’ve been doing it for years. What I specifically meant was: there’s a variable type in Blueprints called a “Class Reference” I am using in my Blueprint, but you never reference “classes” in C++ - only objects (there is an Object Reference type in Blueprints as well).
C++ barely has introspection as it is, so I’m assuming Class Reference is something Epic built on top of C++ in its Unreal Header or Builder Toolkits. Although I should really read through those again.
Thanks! Once I made that change, I could debug the rest of the issues. (1. I forgot to add “#include ‘ControlInputStateBase.h’” and (2) I needed to make a forward declaration due to a circular dependency).
Edit: I still get this Error (but the code still reloads into the Unreal project)
Adding a forward declaration of class AInputStateMachineCharacter; to fix the issue actually causes UE4.25 to crash. The project can “live” without it (ie changes are still sent to the Unreal Engine project), but I am unsure if this will cause any problems later in development.
I’m also changing my variables to use PascalCase like you suggested.