GetActorBounds ignores child actor components & instanced meshes

In case anyone still wants this:

void AYourAmazingActor::GetBoundsIncludingChildActors(bool bOnlyCollidingComponents, FVector& Origin, FVector& BoxExtent) const
{
	FBox Bounds = GetComponentsBoundingBox(!bOnlyCollidingComponents);
	TArray<UActorComponent*> ChildActorComponents = GetComponentsByClass(UChildActorComponent::StaticClass());
	for (UActorComponent* ChildActorComponent : ChildActorComponents)
	{
		const AActor* ChildActor = Cast<UChildActorComponent>(ChildActorComponent)->GetChildActor();
		if (IsValid(ChildActor))
		{
			Bounds += ChildActor->GetComponentsBoundingBox(!bOnlyCollidingComponents);
		}
	}
	Bounds.GetCenterAndExtents(Origin, BoxExtent);
}
2 Likes