for (int32 i = 0; i < modSlot.Num(); i++)
{
UClass *current = Cast<UClass*>(modSlot[i]);
//do something with current
}
You would use AArmorMod pointer if you already had spawned object, but you made array of UClass which are refrence to classes. Most likely you would like to spawn them before doing anything.
()->SpawnActor(current)
And most likely you want to keep return (which will be AArmorMod*)
But you made TSubclassOf array, now it only hold pointers to UClass which is like class identificator not objects, you can’t do much with it other then spawn it or search for objects on level. Maybe this way you will understand, UClass* is a type used in “Class” (purple one) input of SpawnActor node in Blueprint.
//Checking inital armor list
for (int32 i = 0; i < initalMod.Num(); i++)
{
//Spawning armor
AArmorMod *current = ()->SpawnActor<AArmorMod>(initalMod[i]);
//adding spawned armor to slot
modSlot.Add(current);
//Doing things
if (current->hasShield)
{
maxShield += current->maxShield;
}
}
Would be better if you also had functions to adding armor (with UClass* input and spawn if you want) and remove armor so you can do that on the fly during game… thats the basics of inventory system ;]