- Home /
How do I limit my camera viewport to the boundaries of a plane?
I have spent a few days looking for an answer to this. I have a plane that I am treating as my floor. My camera is set up looking straight down on the plane. I can pan the camera around but I don't want the viewport to go beyond the edge of the plane. I cannot figure out how to get the coordinates of the edges of the plane so that I can convert my viewport to world cords to stop the panning when the edge of the viewport reaches the edge of the plane. I am using C# for my scripts.
The code has been posted for this several times in the last year. Here is one post that you should be able to adapt to your use:
http://answers.unity3d.com/questions/468253/how-do-you-clamp-a-camera-by-mobile-width.html
$$anonymous$$y issue is getting the coordinates of the plane not the coordinates of the view port. I'm sorry if I was unclear all I have for my plane is the origin and a scale and i don't know how the scale relates to real world coordinates.
Your answer
Follow this Question
Related Questions
Prevent objects from disappearing when zooming in on an orthographic scene? 1 Answer
In-game video monitor without render-to-texture 0 Answers
WorldToViewportPoint and WorldToScreenPoint give wrong positions when VR is enabled 1 Answer
Move the camera in 2D when target reaches bounds. Is there a better way? 0 Answers