Rotating component around custom point

I’m trying to rotate a Cube around its center but it always rotates around the standard origin, which is at the bottom. I tried to use a quaternion with translation, but that didn’t work. Here is what I tried:

FRotator Rotator = FRotator(Pitch, 0, Roll);
FTransform Transform=Cube->GetRelativeTransform();

Transform.AddToTranslation(FVector(0, 0, -(Max.Z - Min.Z)  / 2 ));  //center point
Transform.SetRotation(Rotator.Quaternion());
Transform.AddToTranslation(FVector(0, 0, -(Max.Z - Min.Z) / 2));
Cube->SetRelativeTransform(Transform);

I din’t find appropriate resources to this problem. Any ideas?

You can simply use this

Cube->AddWorldRotation and Cube->AddWorldOffset for translation

If you look at your “Rotating Component”, you can set your “Pivot Translation” to offset your rotation pivot.

Hope that helps =)

Doesn’t seem to work… it still rotates around the wrong pivot point.

thanks! for me this works.

If your mesh has the orgini shifted from the center of the cube, you could get the bounds of the component and use the origin of the bounds as pivot :slight_smile:

Im not sure what the equivalent of it is in c++, but in blueprints you are able to find the center of mass for an object and get the vector of that.

Add a scene component that rotates and attach your mesh to it. Then you can change the mesh relative transform.

Yeah, that would be my solution too, simply make the cube a child of a scene component, move the cube until the scene component is at the desired pivot oint and then rotate the scene component, since the cube is a child of it it will rotate too, but this time around the scene component as its pivot, good luck! :smiley: