Easy way to focus and frame camera on selected object with blueprint?

I want to develop a functionality where a user will be able to press a button that move the focus of the camera to a selected object and reposition the camera (with a fixed FoV) to frame the object correctly.

In face, I want to reproduce the behavior of the F shortcut in the editor:

In the editor, you can select an object
You can press F key
The camera move put the select object in the center of the view and adjusts the distance (arms length) to make the whole object visible.
Is there an easy way to reproduce that in blueprint? I’m actually doing trigonometry stuff and using bounding box size but I’m pretty sure there is a better way. I don’t want to recreate a feature that may be already accessible (and already developed in the quickpayportal editor).

You could spawn a camera pointing at the object and blend to it.

I have to go at the moment, but will send a BP later if you’re interested…

The move to is easy enough, I guess you won’t have problems with this, so it’s just about the arm length?

I am not quite sure this functionality is accessible in-game… Maybe you can find it in the source code and just duplicate it.

I guess it would still be better to just frame it yourself. This way you can customize it more easily. And I reckon if you don’t have a problem doing some math, you’ll get it done.

Here’s a mock up:



But are you using first person / third person / do you want to point at the object with crosshair or mouse cursor etc?..

( left part )