- Home /
Calculate camera position when angle is change but viewport bottom need to be fixed?
Hello unity answer community, I'm very pleased to meet you all. I'm still novice for unity script programing, if you have sometimes to help me answer this question would be greatly appreciated :)
I'm now making a mobile turn base game, which camera is a top-view style but player is being able to change the view angle to see a little bit further more ahead in perspective.
For example
As from the example above, when the camera angle is change from view A to view C (X-Rotation) the Viewport (Bottom Left) and (Bottom Right) must be still sit on the bottom of the (Ground Plane)
and more importantly the viewport to world point coordinate (Bottom Left) and (Bottom Right) must be still point to the exact (Bottom Left) and (Bottom Right) of the Ground Plane
for example bottom left (0,0) and bottom right (0,100) if my screen width is equal to 100 in world space
Consider if
the camera Z vector is point toward my ground image
my camera projection is perspective
my ground image have to be a fixed size
I cannot just change the pivot and rotating my image because it has some game mechanic involving to it
The problem is if I just change the camera angle (X Rotation) the view angle is change but it also makes my bottom left and bottom right of ground image dose not fit perfectly in the screen anymore. I have to change the camera position (Y) and camera position (Z) to make my image fit again.
Question is How can I calculate camera position (Y and Z position) when the player change the view angle to make the game view looks like it transition from view A to view C in the example picture above
Please forgive me if my question seem a little bit confuse and it dose not explain correctly. I don't really know the keyword to search for the answer of this question, how to make the name of topic and how to explain it. I have been struggling in this problem for many days.
note: the images I use in the picture is been googled for explanation purpose only and I will not use it in my real game.
Thank your for your detailed answers.
Your answer
Follow this Question
Related Questions
my camera show an extremely weird aspect [android] 0 Answers
How can I mimic a Camera from a game to my project? 1 Answer
Camera behaviour when looking directly up or down 0 Answers
How to make my Camera Controller look at target 0 Answers
Camera movement according to rotation and actual position RTS 1 Answer