How do you calculate the distance from the camera so that a GameObject fills the screen? I.e. Without reaching out of the view and regardless of screen orientation.


You can return the difference of transform.position of Main Camera and transform.position of GameObject, if you only want the distance between them.

If you want something else, I think this video might help you


  • 2
    \$\begingroup\$ I think OP is asking not for the current distance between the object & camera, but the required distance they'll need to move the camera to in order for the whole object to fit on screen. \$\endgroup\$ – DMGregory May 11 '19 at 21:34
  • \$\begingroup\$ Sarvagna Shukla, thanks for your contribution. @DMGregory you're right, it's about finding the required distance to make a GameObject fit onto on the screen. I've edited the question to make it more clear. Thanks for your feedback. \$\endgroup\$ – SePröbläm May 11 '19 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.