I have a static mesh imported into my project, which includes simple and complex collision data. I can see both fine in the UE4 mesh editor.
Now I want the bounding box of the simple collision data of a given UStaticMeshComponent in C++. Is there an easy way to achieve this?
Assume that weβre in AActor class.
To get Bound in world space.
// First option.
UStaticMeshComponent* StaticMeshComp = FindComponentByClass<UStaticMeshComponent>();
const FTransform WorldTransform = StaticMeshComp->GetComponentTransform();
FBoxSphereBounds WorldBound1stOption = StaticMeshComp->CalcBounds(WorldTransform);
// Second option.
UStaticMeshComponent* StaticMeshComp = FindComponentByClass<UStaticMeshComponent>();
StaticMeshComp->UpdateBounds();
FBoxSphereBounds WorldBound2ndOption = StaticMeshComp->Bounds;
To get Bound in Local space.
UStaticMeshComponent* StaticMeshComp = FindComponentByClass<UStaticMeshComponent>();
UStaticMesh* StaticMesh = StaticMeshComp->GetStaticMesh();
FBoxSphereBounds LocalBound = StaticMesh->GetBounds();
Hey, thanks for your reply. I was not looking for the bounds of the mesh though, but for the bounds around the simple collision of that mesh. However, I found the solution here:
4 Likes