TMap of TSubclassOf Compile Errors

Good evening UE4,

I’m having some problems with TMaps, as when I combine them with TSubclassOf and try to Cast one of its objects back to the Base Class, it just throws compilation errors at the Class.h - which is obviously not where the problem is:


class MyGame_API MyGame_B : public MyGame_A
{
public:
	.......

protected:
	TMap<FString, TSubclassOf<class MyGame_BaseClass*>> SpawnClassType;




MyGame_B::MyGame_B()
{
	....

	SpawnClassType.Add("ExtendsFromBaseClass", MyGame_ExtendsFromBaseClass::StaticClass());
}
...

bool MyGame_B::DoSmth(...)
{
	....
	//HERE IS THE RROR, Cast
	MyGame_BaseClass* SpawnTargetActor = Cast<MyGame_BaseClass>(SpawnClassType[skill->SpawnActorName]);

I apologize if its getting a big messy, but the idea is: Class B extends from A; Class B contains a Map of all the classes which it can spawn - all of which are subclasses of BaseClass, e.g., ExtendsFromBaseClass. Finally, we try to cast the ExtendsFromBaseClass back to BaseClass - since it includes virtual methods which will then be called by SpawnTargetActor->DoVirtualMethod();

Essentially, the problem occurs with the Casting method.

Any idea what the problem is?

Btw. You can also submit the issue at the Answer hub, https://answers.unrealengine.com/

Remove pointer notation in subclassof usage:

TMap<FString, TSubclassOf<class MyGame_BaseClass>> SpawnClassType;

That was stupid hah thanks mate