I’m trying to use GetAllActorsOfClass() to get all the actors of a “parent piece” class. This class has a variable named “coordinates”, which I want to compare with another variable within the class I’m calling from.
The problem is that I can only access the coordinates variable from a pointer of the parent piece class, but the GetAllActorsOfClass is only returning arrays of actors. The below code is what I have, and it returns an error saying that GetAllActorsOfClass needs 3 parameters.
TArray<AParent_Piece*> PiecesArray = UGameplayStatics::GetAllActorsOfClass(this, AParent_Piece::StaticClass());
for (int32 PiecesIndex = 0; PiecesIndex < PiecesArray.Num(); PiecesIndex++)
{
if (PiecesArray[PiecesIndex].Coordinates = TheseCoordinates)
{
}
}
When I add a change it to this…
TArray<AActor*> PiecesArray;
UGameplayStatics::GetAllActorsOfClass(this, AParent_Piece::StaticClass(), PiecesArray);
for (int32 PiecesIndex = 0; PiecesIndex < PiecesArray.Num(); PiecesIndex++)
{
if (PiecesArray[PiecesIndex].Coordinates = TheseCoordinates)
{
}
}
I receive a new error saying that the class “AActor” doesn’t have a “coordinates” variable. If I replace the “AActor*” with “AParent_Piece*”, it says that GetAllActorsOfClass can’t take an array that isn’t of AActors.
Does anyone know a workaround for this? With blueprint scripting, it’s really easy. But I want to figure this out in C++.
Thanks in advance!