How to get 2d camera width & height?
Hi, I'm trying to learn Unity & also train on C#, so I decided to start simple by making Pong, but I don't understand the 2d camera:
How can I get the height & width of the camera view? (the white rectangle)
I expected to find some numbers like 1280x1024 or similar, but the only slightly relevant number I have found is 5 with the label: Size, which seams to be the radius from center to top & bottom but not sideways
The goal is to program the ball to bounce on the inside of the camera-border so I don't have to "cheat" with placing objects with collision boxes as borders & it would also allow to automatically adjust itself to whatever camera/screen size the player is using, but to do that I need to get the size of the camera view.
Thanks!
Answer by Sensino · Feb 09, 2018 at 07:21 PM
Well, thanks for absolutely nothing!
For future readers, here are some relevant information:
The thing you are looking for is NOT the Camera, it's called the Frustum (that is the "view-port cone" in front of the camera)
Here are a good video about the relations between the frustum size & sprite sizes: link text
In this Wiki article you will find the math for calculate the size of the frustum cone at a specific depth: link text
If all else fails, then try browsing the Unity Asset Store, here is a link to free cameras: link text
Hope you will have better luck than I had with this post!
Answer by Sensino · Feb 07, 2018 at 07:16 PM
Why is no one answering?
Surely most people on here must know the answer to this?
Your answer
Follow this Question
Related Questions
Change camera origin point to top left? 2 Answers
Changing resolution affect camera width but not height 0 Answers
Cinemachine Confiner doesn't confine on the upper boundary 1 Answer
3D objects appear behind 2D on mobile, but in correct order in editor 1 Answer
Blur edges of a 2D camera view 0 Answers