How can you get the center of actor/component when the pivot is off center?

I know there’s getcomponentbounds, getimportedbounds, etc., but I’m at a loss for ideas to get a mesh’s dimensions or center (which those functions imply to be able to do) when the pivot/mesh origin is not at the center of the mesh. This surprises me, because even in the example project for third person, the skeletal mesh’s pivot is offset (it’s at the bottom of the mesh). I can’t find any details either of what direction it measures the box extent from/to when it measures from the pivot location. I would love it if someone could help or provide some clarity.

I believe I found it now… center of mass function should allow me to correct the pivot location as well to get the correct bounds size. I will post back if it works out, unless someone has a simpler solution.

It seems to be working, but it’s not ideal, here’s how I have it set up right now: center of mass to a variable on begin play → origin - CoM - worldLocation + box extent. Seems to be more reliable but it comes to around 1.09x the size it should be, or really 0.545x (box extent should be half size) I have no clue if I did it right but it’s provided useable results in 3 different meshes.

As far as I can tell, the GetComponentBounds and GetActorBounds nodes return an ‘Origin’ vector which is the centre of a box that encloses the input component or actor.

I would think the centre of mass would be a different location from the centre of the bounding box if the mesh isn’t symmetrical in every axis, which might be why you’re not quite getting half of what the box extent should be.

What I’m doing is to use GetActorBounds on an actor that’s attached to an empty parent static mesh. If I subtract the ‘Origin’ vector from the parent’s location, this moves the child so that the centre of the its mesh (rather than its pivot) is at the pivot of the parent. I can then rotate the parent and the child appears to rotate about its centre rather than its own pivot.

I’m not sure why these nodes don’t provide what you need.

I think this might not have been around 2 years ago when the question was asked. But now you can get the center like so

    FVector Min;
    FVector Max;

Mesh->GetLocalBounds(Min, Max);

FVector BoxCenter = FVector((Max.X + Min.X)/2, (Max.Y + Min.Y)/2, (Max.Z + Min.Z)/2);

Get Box extents if you want this way

float XMaxVal = FMath::Max(FMath::Abs(Min.X), Max.X) - BoxCenter.X;
float YMaxVal = FMath::Max(FMath::Abs(Min.Y), Max.Y) - BoxCenter.Y;
float ZMaxVal = FMath::Max(FMath::Abs(Min.Z), Max.Z) - BoxCenter.Z;


FVector BoxExtents = FVector(XMaxVal, YMaxVal, ZMaxVal);

Acotr.GetActorBounds(True,False)

Thank you @UnrealHorrorDev !
Here’s what the code looks like in blueprints :slight_smile:

Try this


The pivot point is off-centered
meshCenterLoc2

2 Likes