how to get the orientedbox

how to get the orientedbox of a mesh or aactor,i did not find any related api .
should i caculate it by self .
thanks for any information or code

My C++ Code For You!

You can do something like this! (did not compile-test this, may have simple errors)

//Get the Bounds!
const FBoxSphereBounds& Bounds = yourActor->GetRootComponent()->Bounds;

Get the FQuat World Space Rotation of the Component:

//Get the Rotation of the Root Component as FQuat! -Rama
FQuat Rotation = yourActor->GetRootComponent()->GetComponentToWorld().GetRotation();

Now to draw the box rotated according to world rotation of the component:

ENGINE_API void DrawDebugBox(const UWorld* InWorld, FVector const& Center, FVector const& Box, const FQuat& Rotation, FColor const& Color, bool bPersistentLines = false, float LifeTime=-1.f, uint8 DepthPriority = 0);



//Draw Rotated Bounds Box!
DrawDebugBox(GetWorld(), Bounds.Origin, Bounds.BoxExtent, Rotation, FColor::Red, false, 3, 0);

Make sure to call GetWorld() inside of an Actor class when testing initially, sometimes getting the world can be harder if operating in a UObject context, and definitely does not work inside a static function.

This code will draw a rotated Bounds box for you!



thanks very much

Welcome to the forums ROBUNliuohu!



As Rama said using it from a static method would be difficult, if it’s only for debug purposes and you just want to try something you could use the global GWorld variable. But please do not use it anywhere in real code and never ever in production :smiley: