So, I modified my AssignMesh() method to include the assignment of a generic material (no texture yet.) Still, the fences are invisible. And yes, I added the appropriate pointer in the *.h file, so everything compiles just fine.
//Assigns the appropriate mesh after creation (called externally)
void AFenceObstacle::AssignMesh() {
if (HeightMarker > 0 && HeightMarker < 9) {
//Assign the appropriate mesh to the fence based on the assigned HeightMarker
auto const Path = FString::Printf(TEXT("/Game/Meshes/sm_obstacle_fence_size_%i.sm_obstacle_fence_size_%i"), HeightMarker, HeightMarker);
auto Mesh = LoadObject<UStaticMesh>(nullptr, TEXT("FenceMesh"), *Path);
if (Mesh) {
VisibleMesh->SetStaticMesh(Mesh);
static ConstructorHelpers::FObjectFinder<UMaterial>Material(TEXT("'/Game/Materials/wood.wood'"));
if (Material.Succeeded()) {
MaterialInstance = UMaterialInstanceDynamic::Create(Material.Object, VisibleMesh);
}
VisibleMesh->SetMaterial(0, MaterialInstance);
}
}
else {
//If an erroneous HeightMarker value was assigned, show that in a debug message
check(GEngine != nullptr);
//Display a debug message for five seconds
//The -1 "Key" vale argument prevents the message from being updated or refreshed.
auto const err_msg = FString::Printf(TEXT("AssignMesh: Invalid fence height value: %i"), HeightMarker);
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, err_msg);
}
}