Object Object Mesh is not aligned with Bounds


I’ve been trying to snap my objects to ground. To do this I calculate object’s height to ground by using linetraces. Then I adjust Z location of actor accordingly. However, some object have bounding boxes (i am not sure if this is the correct term) which are not aligned with their static meshes. For example:

This cube mesh has a perfectly fine box, you can see its box with red lines.

But this chair object has box like this (you can see it is snapped to ground correctly according to this box):

I added these boxes according to UStaticMeshComponent of objects like this:

Box = NewObject<UBoxComponent>(CurrentActor);

How can I fix this without editing in 3D software? Is there a reason why it is like this? I downloaded this chair object from marketplace. The problem here is that boxes are not persistent so I cannot simply offset Z location according to box size.

I cannot see the images for the some reason, but are you sure this isn’t a problem with proper attachment setup for the box component? I recall I had issues where the components I add receive some weird offset relative to other components of the actor. Is the code you provided all that you are doing? I was expecting something along the lines of:

Box = NewObject<UBoxComponent>(CurrentActor);

If SetupAttachment does not work, try:


I use SetupAttachment and RegisterComponent like you said. I will try to reupload images.

Boxes work correctly for objects created with editor like sphere, cube etc. Can the problem be the files that I downloaded?

Cant you just edit the chair collision in the mesh editor?

I will try that, thanks.

From the looks of it, it feels like the pivot point of the chair model is at the center, and not the bottom of the chair. If that is the case, then the easiest solution is to modify it in a 3D editing software. Theoretically you can fix it in code by offsetting your box in the Z direction by half the height of the mesh bounding box - but that would falsely assume all meshes have their pivot incorrectly placed.

Theoretically, would you be able to do something like this?

FBoxSphereBounds boxBounds = Box->CalcBound(Box->GetComponentTransform());
if(boxBounds.Origin.Z != Mesh->Bounds.Origin.Z)
    // Do code to correct for z-mismatch, find the difference and offset by that

At the moment I am unable to try it but I will try it tomorrow. I think it would solve the problem, but I would prefer bounds to be correctly aligned with mesh. Thanks for the idea.