Thanks I got it to work, my test code:
PrimaryComponentTick.bCanEverTick = false;
this->SetMobility(EComponentMobility::Static);
SMC = CreateDefaultSubobject<UStaticMeshComponent>(FName("PleaseDontCrash"));
SMC->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
SMC->SetMobility(EComponentMobility::Static);
SMC->SetStaticMesh(ULib::CreateObject<UStaticMesh>(P_WALL_MESH));
But then I have no idea why it crashed before. But I’m not gonna complain, the code is and was good then. Thanks!
P.S. Also make sure to add this line:
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )