I thought that too, but UMiniMapElement is a UActorComponent, not a USceneComponent so it doesn’t have attachment. What’s weirder is that in the editor, I can see the element in the list on the actor.
You might want to do something like this, to get a better understanding where that call is falling apart (I am guessing how your classes are setup so you’ll need to fill in some gaps):
if(MapElement)
{
UEmpiresGameModeBase* GameMode = UEmpiresFunctionLibrary::GetGameMode(this);
if(GameMode)
{
TArray<UEmpiresTeam*> Team = GameMode->GetTeam(TeamName);
if(Team.Num( ) > 0)
{
Team->Map->AddElement(MapElement);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Failed to get team back from GameMode");
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Failed to get game mode!");
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Map element is nullptr.");
}