Hello, Basically, I have a bunch of objects in my game and I want them to get a color each of them. I have a table of the RGB values for the 61 objects of them. I want to create a function in my blueprint function library that will ask for a integer, and it will return in the FColor from the array. I just have some questions on how to initialize the array out.
Inside of my FunctionLibrary Class, do I just create the following?
private:
TArray<FColor> ObjectColors = {FColor(255,255,0,255),
FColor(255,220,0,255),
FColor(255,190,0,255),
...
FColor(0,255,255,255) };
Then, on the CPP function to get the value, I am doing the following
FColor UMyBPFunctionLibrary::GetFColorForObject(int Index) {
if (Index < 13 || Index > 73)
{
return FColor(255, 114, 143, 255);
}
return ObjectColors.GetData(Index-13);
}
But it fails at the last return line. I get on Visual Studio an error underlining ObjectColors with “a nonstatic member reference must be relative to a specific object”.
So, how do I create a TArray variable, write in the values for each element, then use a function to get one of the values?