Above is what my grid looks like after loading my umap. The following is what it is saved as (wall tiles are procedural at the moment so they are in different spots):
I can regenerate my grid just fine, and it works as expected. I also create the instance static mesh components the same way. Here is the code:
bool AHexGrid::AddInstancedStaticMeshComponent(EHexType type, const TCHAR* mesh, const TCHAR* name, const class FObjectInitializer& PCIP)
{
ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(mesh);
//create new object
UInstancedStaticMeshComponent* instancedMeshComponent = PCIP.CreateDefaultSubobject<UInstancedStaticMeshComponent>(this, name);
//Not Made for some reason?
if (!instancedMeshComponent) return false;
InstancedHexComponents.Add(type, instancedMeshComponent);
instancedMeshComponent->AttachTo(RootComponent);
//Set to Asset
instancedMeshComponent->SetStaticMesh(Mesh.Object);
instancedMeshComponent->bOwnerNoSee = false;
instancedMeshComponent->bCastDynamicShadow = false;
instancedMeshComponent->CastShadow = false;
//Visibility
instancedMeshComponent->SetHiddenInGame(false);
////Mobility
instancedMeshComponent->SetMobility(EComponentMobility::Static);
//Collision
instancedMeshComponent->BodyInstance.SetCollisionEnabled(ECollisionEnabled::QueryOnly);
instancedMeshComponent->BodyInstance.SetObjectType(ECC_WorldStatic);
instancedMeshComponent->BodyInstance.SetResponseToAllChannels(ECR_Ignore);
instancedMeshComponent->BodyInstance.SetResponseToChannel(ECC_WorldStatic, ECR_Block);
instancedMeshComponent->BodyInstance.SetResponseToChannel(ECC_WorldDynamic, ECR_Block);
return true;
}
AHexGrid::AHexGrid(const class FObjectInitializer& PCIP)
: Super(PCIP)
{
gridShape = EGridShape::Hexagon;
maxQ = 10;
if (!AddInstancedStaticMeshComponent(EHexType::Floor, TEXT("StaticMesh'/Game/Meshes/hextile.HexTile'"), TEXT("InstancedFloorTile"), PCIP))
{
ERROR("Failing floor...");
}
if (!AddInstancedStaticMeshComponent(EHexType::Wall, TEXT("StaticMesh'/Game/Meshes/hex_wall.hex_wall'"), TEXT("InstancedWallTile"), PCIP))
{
ERROR("Failing floor...");
}
if (!AddInstancedStaticMeshComponent(EHexType::Start, TEXT("StaticMesh'/Game/Meshes/hex_wall.hex_wall'"), TEXT("InstancedStartTile"), PCIP))
{
ERROR("Failing floor...");
}
if (!AddInstancedStaticMeshComponent(EHexType::Flag, TEXT("StaticMesh'/Game/Meshes/hex_wall.hex_wall'"), TEXT("InstancedFlagTile"), PCIP))
{
ERROR("Failing floor...");
}
}
Why do they disappear?
Here is how they are declared:
TMap<EHexType, UInstancedStaticMeshComponent*> InstancedHexComponents;
It is NOT a UPROPERTY.
Lastly, when loading, i get the following output LoadError:
[2015.07.12-19.05.13:613][328]LogFileHelpers: Loading map ‘JoeTest’ took 1.998
[2015.07.12-19.05.13:626][328]LoadErrors:Error: Error Failed import for InstancedStaticMeshComponent /Game/Blueprints/HexGridBP.Default__HexGridBP_C:InstancedFloorTile
[2015.07.12-19.05.13:627][328]LoadErrors:Error: Error Failed import for PhysicsSerializer /Game/Blueprints/HexGridBP.Default__HexGridBP_C:InstancedFloorTile.PhysicsSerializer
What is strange is that instaced floor tile appears to be loaded fine, but instancedWallTile does not. (unless my makeshift instanced start tile is the one that fails to load (i don’t have a mesh for that one yet).