Scale objects to maintain screen size when camera moves

I am making an application and encountered an intereseting problem.
In my application I would like to have some actors to maintain their screne size whenever the perspective camera gets further away / closer to them. Since I am also running collision checks with the said actors, I am unable to create that effect using an orthographic camera.

What I would need is some sort of formula which takes into account camera paramaters (fov, screen size) and the actor’s distance from the camera, and returns a scalar which can be multiplied with the actor’s scale, such that it maintains the same screen size whenever the camera moves.

I suspect the solution involves pretty basic trigonometry, but I wasn’t able to figure it out myself.
Any help in the form of a blueprint script or C++ code would be much appreciated!

Edit : I forgot to stress that my application involves changing the screen size and field of view, so simply scaling the actor lineraly based on its distance from the camera would not be sufficent.

You could try it like this, it’s crude but it might be the first step towards the end result:

This would work perfectly fine as long as the screen size or field of view do not change, but I am afraid this isn’t the case for my application (I was not clear enough that in my question, my bad).

I need this for a runtime Gizmo I’m trying to implement. The Gizmo is a 3D Object.
This helped me, but its not perfect: With a perspective camera: Distance independent size gameobject - Unity Answers

Did you find any other solutions?

Ted-Bighams answer in the link is working, but only if i use 1 for sizeOnScreen… This gives me a nice working scale factor… Even with changing the FOV…