Hello,
I’ve been trying to create a generated wooden floor actor using C++.
I’m creating a StaticMeshComponent for each plank and add this to actor’s Root Component.
UStaticMeshComponent* AGeneratedFloor::CreatePlank(FName name, float y, float x, float scaleLength, float scaleWidth, UStaticMesh* mesh)
{
UStaticMeshComponent* tmp = NewNamedObject<UStaticMeshComponent>(this, name);
(*tmp).RegisterComponent();
(*tmp).SetStaticMesh(mesh);
(*tmp).SetRelativeLocation(FVector(y, x, 1.0f));
(*tmp).SetRelativeScale3D(FVector(scaleWidth, scaleLength, 1.0f));
(*tmp).AttachTo(GetRootComponent());
return tmp;
}
However I stumbled upon a problem with clearing said components from root (for example on floor size change) and could not find solution here or anywhere else on the internet.
So my question is, what is the correct way of clearing root of it’s components?
Thank you for your time and effort.