Hi community,
I am new in Unreal programming so please forgive the probably evidence of my question.
I am doing some tests with InstancedStaticMesh that seems to work quite good in editor mode, but crash in GameMode (Play in the editor).
Could you explain to me why please?
Crash happens when i replace the Floor->AttachTo(RootComponent) by RootComponent = Floor;
Is it forbidden to have an InstancedStaticMesh as RootComponent?
The crash seems to happen when trying to get a Body for something (debug assertion).
Thanks for your time.
UCLASS()
class TEST_API AMeshSet : public AActor
{
GENERATED_BODY()
public:
/** a static Mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Test)
UInstancedStaticMeshComponent* Floor;
/** a static Mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Test)
UInstancedStaticMeshComponent* Pillar;
AMeshSet(const FObjectInitializer& ObjectInitializer);
UFUNCTION(BlueprintCallable, Category = Dungeon)
void Reconstruct();
};
AMeshSet::AMeshSet(const class FObjectInitializer& PCIP)
: Super(PCIP)
{
Floor = PCIP.CreateDefaultSubobject<UInstancedStaticMeshComponent>(this,TEXT("Floor"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> floorStaticMesh(TEXT("StaticMesh'/Game/StarterContent/Architecture/Floor_400x400.Floor_400x400'"));
Floor->StaticMesh = floorStaticMesh.Object;
// RootComponent = Floor;
Floor->AttachTo(RootComponent);
Pillar = PCIP.CreateDefaultSubobject<UInstancedStaticMeshComponent>(this, TEXT("Pillar"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> pillarStaticMesh(TEXT("StaticMesh'/Game/StarterContent/Architecture/Pillar_50x500.Pillar_50x500'"));
Pillar->StaticMesh = pillarStaticMesh.Object;
Pillar->AttachParent = RootComponent;
Reconstruct();
}