I feel what I’m trying to do is fairly simple but I can’t get it working because of a type conversion issue.
I have a class (PlanetManager.cpp) that I want to include a static array of planet names (TArray) and then when the game starts I want to grab some random planet names from that array to use.
In my .h:
...
private:
static TArray<FString> planetNames;
...
And then in my .cpp:
UPlanetManager::UPlanetManager()
{
...
UPlanetManager::planetNames[10] = {
"Zephyria", "Aurora Prime", "Nebulon-9", "Elysium-IV", "Galactica", "Nova Terra", "Stellaris-Alpha", "Celestia", "Luminara", "Orbitus-Minor"
};
...
}
...
void UPlanetManager::GeneratePlanets()
{
for (int i = 0; i < planetCount; i++)
{
FString planetName = UPlanetManager::planetNames[i];
//do something with planetName
}
}
However when I try to create the planetName
variable inside GeneratePlanets()
I get the following error in VS:
no suitable user-defined conversion from "TArray<FString, FDefaultAllocator>" to "FString" exists
I’m not quite understanding why the type of an individual element is not an FString with the way I’ve set it up.
Any help would be greatly appreciated.