I am trying to create system of buildable block. In order to that I attaching meshes to actor.
Attaching works pretty well but actor collision is not update by attached meshes and i don’t know how to fix it.
This is my attaching function:
void AVoxelizedObjectV2::AddVoxelMesh(FVector location, FRotator rotation)
{
//Create new Component
UStaticMeshComponent* NewStaticMeshComponent = NewObject(this);
//Set VoxelMesh as ComponentMesh
NewStaticMeshComponent->SetStaticMesh(VoxelMesh);
//Reigster Component with World
NewStaticMeshComponent->RegisterComponentWithWorld(GetWorld());
//Attach NewStaticMeshComponent to RootComponent
NewStaticMeshComponent->AttachTo(RootComponent, NAME_None, EAttachLocation::KeepRelativeOffset, true);
//Set NewStaticMeshComponent location and rotation
NewStaticMeshComponent->SetRelativeLocation(location);
NewStaticMeshComponent->SetRelativeRotation(rotation);
}
I already try to read this tutorial A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums but it works with custom generated meshes, I adding cube meshes to actors. I think about UBodySetuo but I don’t know how to acces it from actor class.