To get mesh size in C++ code:
auto MeshComponent = Cast<UStaticMeshComponent>(Actor->GetRootComponent());
auto StaticMesh = MeshComponent->GetStaticMesh();
auto Bounds = StaticMesh->GetBounds();
It will return FBoxSphereBounds
struct which has SphereRadius
and BoxExtent
and of course Origin
Then you can use code like this:
FRotator Rotator = Actor->GetActorRotation();
FVector RotatedVector = Rotator.RotateVector(Bounds.BoxExtent);
But remember, the RotatedVector
will be rotated BoxExtent
and if you will use it in axis aligned coordinates it wont give you results that you want. E.g. if you will try to use it in DrawDebugBox
. At least, it should make your life easier.