I have a this code trying to use a temp array to access variables.
But I get an error that it has no conversion from Subclassof to Tarray.
any help would be appreciated thanks
Test.h
// gets set from blueprint defaults
TArray< TSubclassOf<MyClass> > MyClassList;
void shuffleMyClassList();
Test.cpp
void Test::shuffleMyClassList()
{
TArray<AMyClass*> LocalArray;
for (int i = 0; i < MyClassList.Num(); i++)
{
AMyClass* TempInfo = MyClassList[i]->GetDefaultObject<AMyClass>();
LocalArray.AddUnique(TempInfo);
}
}
Ok, things I see in the code:
-
“TArray< TSubclassOf < MyClass > MyClassList;” should be “TArray< TSubclassOf < AMyClass > > MyClassList;”.
-
You are iterating over the size of MyClassList, but then accessing TeamList[i] (not necessarily wrong, but make sure it’s not a copy-paste mistake, happens sometimes ;P). Also, I have no idea what type TeamList is, so the problem could be there.
-
When you access GetDefaultObject, make sure the CDO is what you want, and not the actual object.
yea I was typing half asleep after banging my head against the wall trying to solve this problem.
anyways I have fixed the typo errors.
so the MyClassList is a list of blueprints derived from AMyClass. I am trying to get those and then put them inside a temp array to sort them.
You should add the full compiler error message, to make it easier for us.
sadly sleep solved the problem I had a typo. The above code will work properly if you type it in correctly 