How to make a ProceduralMesh child of an Actor in c++?
For now I want to make an actor for evry proceduralmesh in my game, and then hook the proceduralmesh onto each actor. Since I’m not managing making it child earlier, I’m executing the code in blueprint. I now have this, which isn’t working (it does’nt become child, it does spawn all my actors):
for (int iCtr = 0; iCtr < m_AllMeshComponent_Plate.Num(); iCtr++)
{
AMyMeshActor* pMyMeshActor = SpawnNewMyMeshActor();
UMyProceduralMeshComponent* pMeshComponent = m_AllMeshComponent_Plate[iCtr];
RootComponent = pMyMeshActor->GetRootComponent();
pMeshComponent->AttachTo(RootComponent);
}
I execute this code in begin play in the level blueprint.
Update next try: following code Fails
AMyMeshActor* pMyMeshActor = SpawnNewMyMeshActor();
UMyProceduralMeshComponent* pMeshComponent = m_AllMeshComponent_Plate[iCtr];
pMeshComponent->SetupAttachment(pMyMeshActor->GetRootComponent());
Thank you for your time