- Home /
How would I go about constructing a layered scene?
Right So watching the Unity showreel i noticed the game Max & The Magic Marker It inspired me to create a game along the same lines, I'm completely new to Unity and I would love to know how on earth I go about transferring my artwork onto a layered background.
Example: http://www.youtube.com/watch?v=atgyo5SQ_jU
Please help! - Caius
Answer by alpine 2 · Aug 10, 2010 at 02:52 PM
Use 3d planes with alpha, stacked up at different distances to achieve the parallax effect. Use a script to rotate them toward the camera.
Thank you, would you go as far as providing the appropriate script for rotating them towards the camera, would make my day :D thanks - Caius
The camera rotation is only necessary if your camera is not locked on a 2d plane.. If it's completely locked down (think $$anonymous$$ario NES, compared to say, Little Big Planet) I don't have unity available right now, but it should be something like: [code]
var target : Camera;
function Update() { var n = target.transform.position - transform.position; transform.rotation = Quaternion.LookRotation( n ); }
[/code]
Ok, apparently I can't figure out how to use code formatting on here.
Thank you, although I'm still not following completely, I'll have a play around and research but if you have any links to illustrate what i'm trying to achieve please share them. - thanks
The only reason you need the planes to lock to the camera is if there's any kind of rotation. Otherwise you would see the 2d planes. If it's a purely 2d camera with no rotation, you wouldn't need to do that since you'd always be looking at the planes head-on.
Answer by Bampf · Oct 07, 2010 at 04:58 PM
An alternative to single camera is to use two or more cameras. By default they will both render to the entire screen. You set the depth of the cameras to determine which one renders first, and you set the clear flags of the later camera(s) so that it keeps the image from the first camera as the background.
This approach has a disadvantage, that the two cameras won't automatically move in sync. You may have to write a script to move the background camera (slowly) as the foreground camera moves with the player.
But this approach may occasionally be useful. Examples:
- With the single camera solution, if the background plane needs to be very far away you might have issues with clipping planes and z-precision.
- If parts of the background sometimes move independently of the foreground, for instance if they are on a vehicle and you want to show the background scenery moving by.
- If you want to avoid interaction between the layers. For example, if there were objects that travel away from the camera and you find them running into the background plane.
I just thought it would be useful to mention this option. But I would start with the single-camera approach (alpine's answer) and add more cameras only if you need to. I'm guessing you won't.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070918im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Background Image in a 2D game: problems of size/quality importing. What's the right workflow? 1 Answer
Background Bitmap 3 Answers
How can I unfocus and fade my background in a 2D game? 0 Answers
Unsmooth camera on sprite diffuse 0 Answers
How to make a simple "That's all folks!" effect in 2D? 1 Answer