# Drawn bounding box is wrongly orientated

**URL:** <https://forums.unrealengine.com/t/drawn-bounding-box-is-wrongly-orientated/487002>\
**Category:** World Creation\
**Tags:** sweep, bounding-box, unreal-engine, Physics, Collision, CPP, question\
**Created:** [August 3, 2021, 11:15pm UTC](https://forums.unrealengine.com/t/drawn-bounding-box-is-wrongly-orientated/487002 "2021-08-03T23:15:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![HiredIceSpecter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HiredIceSpecter](https://forums.unrealengine.com/u/HiredIceSpecter)\
**Post date:** [August 3, 2021, 11:15pm UTC](https://forums.unrealengine.com/t/drawn-bounding-box-is-wrongly-orientated/487002/1 "2021-08-03T23:15:58Z")

</div>

I am spawing a level procedurally at runtime. For that I am using UHierarchicalInstancedStaticMeshComponents to populate it for performance reasons. I try to check if an objects already exists in the location I want to spawn in by using SweepMultiByChannel at the position with properly rotated bounding box of the mesh.

At least that is what I want to. When checking what my code does with DrawDebugBox I get boxes that are incorrectly rotated for some yaw values:

![345581-screenshot00000-70-60.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/7/bb71aa71712af97eab8c6b6791efa3dc11ef0f23.png)

Green text means correct aligned/rotated box, red means incorrect. I am sorry for the bad lighting in the screenshot.

Following the code that I used to draw the bounding box and check for collision/other meshes:

```
FCollisionShape shape;
FBoxSphereBounds bounds;
FTransform transform;
transform.SetLocation(LocationWorld);
transform.SetRotation(FQuat(RotationWorld));
transform.SetScale3D(Scale);
StaticMesh->BodySetup->AggGeom.CalcBoxSphereBounds(bounds, transform);
FBox bbox = bounds.GetBox();
FVector boxExtend = bbox.GetExtent();
shape = FCollisionShape::MakeBox(boxExtend);

FVector	tracePos = bounds.Origin;

DrawDebugBox(GetWorld(), tracePos, boxExtend, FQuat(RotationWorld), FColor::White, true);

TArray<FHitResult> OutResults;
const bool hit = GetWorld()->SweepMultiByChannel(OutResults, tracePos, tracePos, FQuat(RotationWorld), ECollisionChannel::ECC_Camera, shape);

```

I have isolated this code from my spawning system and placed it in BeginPlay() of a StaticMeshActor to be sure the problem is not caused by something else.

What am I doing wrong?
