- Home /
Which Camera projection should I use for 2D game in Unity 4.3
Hi, I am new bee in Unity 3d, and I want to know that which camera projection should I use? When I set this to perspective its has broad view and when I set this to Orthogonal it has rectangle shape camera, So I am bit confuse that which Camera projection use, I also googled but couldn't find any clear hint that which Projection should I use when developing 2D game?
Unity is just copying camera types that have been around for a long time (Orthographic and perspective.) Unity purposely has them work "the same way" as everyone else does.
This means Unity doesn't bother explaining them too much. For a good explanation, just do a general web search. Whatever you find, will 95% apply to Unity.
Answer by Spinnernicholas · Dec 27, 2013 at 06:19 PM
Perspective Camera will work just fine. Use the Sprite Renderer's Order in Layer Property to set the rendering order of your sprites.
Answer by chirhotec · Dec 24, 2013 at 07:53 AM
This is probably a question that is better off in the forums, as its answer is subjective and open for the discussion. But to give a brief solution....
It depends on what you are trying to do :D
If you plan to do sprite based stuff, orthogonal is the way to go. And actually, if you set up your project to use the 2D settings (either on project create, or at Edit > Project Settings > Editor > Default Behavior Mode), it should automatically set the imported camera to orthographic.
If you are doing a "2.5D" game (2D gameplay, 3D assets), and want the subtle perspectives when moving past objects, then you may want to use a perspective camera. See, for example, Donkey Kong Country Returns.
In the past, some folks have also used perspective projection with sprites, to create a parallax effect with background images, but this can cause your sprites to appear less crisp. You could also achieve the same effects with an orthographic camera and some scripting. (not sure if 4.3 has any built in tools to directly solve this problem. See the 2D gameplay demo in the asset store).
...and for the Perspective camera, increase the distance and drop the field of view. As you get further back (and have a smaller angle to see the same area) the camera gets more and more orthogonally. For 3D objects, this gives a tiny bit of perspective.
Can eyeball the numbers, but the exact equation is camDist = gameWidth/sin(FieldOfView)
@Owen Reynolds Thanks for answering. I am getting bit confuse about camera view angle. I have road sprite image and car sprite image. Road image is quite long and what I am doing I am running car with camera onto this road image. When camera and car reached to the middle of road car hide for split second and then show I also change image but same result. I tested and analyze few hits and find that car hide due to camera angle because when it hide it can be show by other camera angle. I don't know how to tackle with this and I am stuck over here. $$anonymous$$indly help me on this. Thanks in advance.
The type of camera shouldn't have anything to do with "popping."
Say you want the camera to see an area 20 meters wide, and you use x&y for the game. An orthogonal camera would just set a width of 20 and angle of 0. It won't matter how far back it is (the amount of -z.) It always sees 20 wide.
If you want a regular camera with a small angle, you still aim at angle 000. But you have to pick to correct -z and angle to get 20 meters wide.
But either way, you still slide the camera around (maybe) on x&y and always get 20 meters on the screen.
aleem, are you having that problem with a perspective or orthographic projection?
If orthographic, I'm not really sure what the issue is. maybe that the car and the road are on the same sorting layer, and are therefore fighting with other for which to be drawn first.
If you are using a perspective camera, its likely that the road's center point becomes closer to the camera than the car's center point. Since the road is therefore "closer" than the car its drawn on top.
You should really watch some of the documentation videos on Unity's new 2D system: http://www.youtube.com/watch?v=B1F6fi04qw8 http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-overview v=4qE8cuHI93chttp://unity3d.com/learn/tutorials/modules/beginner/2d/2d-controllers
Apparently they've even taken care of parallax. So, if you are using sprites, there is no reason to use a perspective camera
@chirhotec Thanks for answering, I am using Perspective Camera ins$$anonymous$$d of Orthographic, because orthographic remain on single angle and just have width variation. I am new in Unity and don't know when and why use Orthographic and Perspective camera, can you please share with me helping tutorial or any link for this. One thing more the point you are telling about perspective camera "If you are using a perspective camera, its likely that the road's center point becomes closer to the camera than the car's center point. Since the road is therefore "closer" than the car its drawn on top." I am 80% sure this happen because of what you are telling, what will be the solution for this to handle this issue. Thanks again.
Answer by abuki · Mar 25, 2016 at 11:21 AM
You can use combination of perspective and orthographic camera. Check my article: http://gamasutra.com/blogs/MichalBerlinger/20160323/268657/Combining_Perspective_and_Orthographic_Camera_for_Parallax_Effect_in_2D_Game.php