Camera view on multiple object?

Hi, So i couldn’t find anything regarding this topic or atleast nothing i could find my self…
How would i go about moving my camera so it renders/are in view of all objects from an array?

Anyone? :slight_smile:

Bump :slight_smile:
Still haven’t figured it out yet

2 Weeks later, still haven’t figured it out yet?
Anyone? :slight_smile:

Are you asking how can you have a camera move based on the position of the objects in array so that all objects are always visible?

Yep, that is exactly what am looking for

I’m not where I can mess around in Unreal to get specifics at the moment but here’s how I would approach it.

I would start by looping over the objects in the array → get their location → then store the highest and lowest values for X, Y, Z. I would consider the highest and lowest X and Y plus the highest Z value as what I want to make sure is visible in the camera.

Then I would assume I want to place the camera in the center of the plane so my X and Y are lowest X + Highest X /2 and Y lowest Y + Highest Y/2. Using some fun triangle math I would use the distance from lowest X to my new camera X and my 1/2 my cameras FoV to find how far up on the Z axis my Camera needs to be.

So for example lets say my Lowest X and Y are -500 and -250 respectively and my highest are 500 and 250. We’ll also assume a 80 degree FoV on my camera. So my Camera X and Y would be 0, 0 and and my Z would be my highest Z value + 595.9. I have included a screenshot below for reference on the math.

Now that being said this is really just a starting point for how you can approach it. Depending on exactly what you need from your camera you may need to change how you are finding you “viewing plane” but I would think this should provide you a base to get there.

image

2 Likes

Thank you so mutch, i’ll give it a try later on today. I’ll come back to you with an update :slight_smile: