-1

I need move unity3d camera to position in which camera will cover all selected object. I mean position in which all selected points will be inside camera frustrum. How to calculate camera position?

Like in this example: enter image description here

code11
  • 1,780
  • 5
  • 29
  • 35

1 Answers1

0

Put all the objects in an array, than compare the distance between all of them and take the biggest one.

Then you just have to make a calculation and apply that to your camera fov/range so that it covers all the objects.

I already made something like this before this way in Unity 2D, so it should be possible in Unity 3D. The problem is that I couldn't find the source of the Unity project but I did found a game exe.

Link to zip (I will update this if I can find the project)

NLxDoDge
  • 154
  • 1
  • 12
  • "then you just have to make a calculation and apply that to your camera fov/range so that it covers all the objects." - Hah. That is think I asked about – Dmtriy Ilchenko Apr 13 '17 at 12:54
  • With the calculation I mean the correction. ` 2D: Camera.main.orthographicSize = MaxDistanceInBlocks; 3D: Camera.main.fieldOfView = MaxDistanceInBlocks; ` – NLxDoDge Apr 13 '17 at 12:59