- Home /
Restricted 2D camera movement area?
Hello,, i have object(fish) move in 2d vector and when object get near camera left or right edge then camera will move so show the rest of scene (plane)..and i want to restrict camera movement for some values in left and right not every player object move to left or right the camera will move to infinite postion i used like this:
camera.position.x = Mathf.Clamp(camera.position.x,-9,9);
where -9 camera position when camera bounds see left plane(scene) edge. and 9 camera position when camera bounds see right plane(scene) edge. however these two values -9,9 woks good in free aspect resolution and when i lower game resolution(for mobiles) then these values becomes wrong and camera not show all scene because camera bounds changed what i should do to get values works in all camera resolution.??
Answer by robertbu · Jul 29, 2013 at 05:16 PM
Here is one answer that has the info you need:
http://answers.unity3d.com/questions/501893/calculating-2d-camera-bounds.html
Your answer
Follow this Question
Related Questions
Camera movment 1 Answer
Js to c# conversion 1 Answer
Getting Camera and Character to be in sync 0 Answers
How to make camera position relative to a specific target. 1 Answer
How to freeze the rotation or the position on the camera transform? 1 Answer