How to get the center location of a bounding box that has been converted to screenspace?

Hello,

I am working on a camera system that will always keep a few selected characters in the frame. I have 4 characters. By using the bounding boxes (blue boxes), I was able to create a box in screenspace that perfectly encapsulates all of the characters (Green box). I need to center the greenbox in the camera view.

My issue is that I am having trouble converting the center of the green screen space box back to world space for the camera to center on. I tried converting/deprojecting the screenspace point to world space, but the issue is that the camera will be dependent on that midpoint location.

What’s the reason you cannot place the springarm here:

And then adjust its length?

Yes, that was the very first option I looked into, however getting the average does not work well when you have an outlier that is far away from the average location. let’s say we have 10 actors in close proximity of each other and then the 11th actor that is far off. That 11th actor will essentially be ignored. I need to use to use bounding boxes relative to the screen to account for all actors, regardless of the average and distance.

Got it, makes sense.

  • consider this then as an alternative:

May have kinks to iron out, may need better math than Max * Coefficient.


trouble converting the center of the green screen space box back to world space for the camera to center on

Try something along the lines of:

1 Like

Wow, thank you for taking the time to put this together for me. I’ll try it!

1 Like