This article may also be useful if you want to make some part of your game "purely" 2D and have other bits be more realistic 3D meshes.
|Unfortunately you'll still have a lot of work ahead of you to make backgrounds this gorgeous *sigh*|
First we need 2 cameras:
- A main camera (the orthogonal one) - This one will render nearly all the game
- A second camera, a perspective one - This will render just our backgrounds
Make the second camera follow the main camera. In Unity3D you can simply make it a child GameObject to save yourself a small amount of coding. Also make sure the main camera is drawn first. In Unity this is done by adjusting their depths (0 for the main camera, -1 for the background).
Now the fun part: The main camera should NOT draw the background. This may vary depending on the engine you're using. In Unity you can simply put the backgrounds on a different layer and tell the main camera not to draw it using an occlusion mask. Make sure any empty space rendered by the gameplay camera will fail the depth-test (on Unity this means setting the Clear flag to "Don't Clear").
Make the second camera draw nothing EXCEPT objects in the background layer.
How this worksThe first camera will be set to draw all the foreground items and will leave empty space for the second camera to draw on. The second camera will draw the backgrounds in that empty space, using perspective, doing precisely what a parallax scrolling effect tries to replicate.
Here's a couple of animations showing the game in pure orthogonal mode and with our "paralax scrolling".
|Entire game in orthogonal projection|
|Backgrounds using perspective camera|
Post a Comment