How to rotate a static mesh component around point in c++?

Hello.
My problem concerns rotating a static mesh around point. Is there any way to change pivot point dynamically in c++? Let just say that, I have a pencil, and it has 4 degrees of freedom (yaw, pitch, roll and insertion). It can rotate around pivot point but when the insertion changes the pivot point location should not change. I mean — when the pencil moves forward/backward (in local space), the pivot position doesn’t change. I think that the best way to reach that “effect” is changing rotation point, isn’t it? How can I change it then?

Is your pivot point a point in space, or another actor? Does the pivot point move over time? The way i do it is i set the root component of the actor that i want to return to the pivot point, and instead move the component i want to rotate around, not the actor.

You can setup the root of the component to be at the center of the point you want to rotate around, but I personally prefer to be able to set these points dynamically as it makes for better asset re-use.

The method described here should help you define a point you want your actor to rotate around without having to modify the actor itself. I’d probably put this as an actor component rather than an actor itself, but it depends on your needs: https://unrealcpp.com/rotate-around-vector/