I’m using GetActorBounds to create a bounding sphere around my actor. I get the box extents and use it to find the box diagonal and use that as the radius for a SphereCollision.
Everything works fine, but when i rotate my actor it affects the results of GetActorBounds, changing the radius of the sphere for any rotation values different from 0, 90, 180 and 270.
My question is: how can i get the actor bounds ignoring its rotation?
Use this cached bounds value to avoid the changes in bounds with rotation.
This is not ideal though, since not all actors are perfectly square or spherical you might want to add some offsets to the cached bounds to cover the actor in all rotations.
Be aware that the Extent of a box changes if you rotate it’s contents: it is calculated from the center to the most distanced point, but stays a box. When I applied the box extent of a component to a collisionbox size and rotated the collisionbox to the world rotation of the actor, it kept pretty good measure. This applies to sphere collisions too.
It did work for me in UE4.26. It’s not affected by the actor rotation, but it’s affected by the components’ local rotation.
Then inside that function, it uses USceneComponent::CalcBounds(const FTransform& LocalToWorld) which is pretty interesting for anyone working with bounds that are not Axis Aligned.
You need to create the function GetComponentOrientedBoundingBox by adding the c++ code that you can see in the comment above in order to use it as a node in the blueprints.
The function CalculateComponentsBoundingBoxInLocalSpace exists in the Actor class but it is not exposed to blueprints.