- Home /
Is it possible to have perspective and orthographic objects viewed simultaneously?
Hi everyone, I am in the process of building a 2D game, using sprites on planes viewed from the side in orthographic perspective for the player and most of the scenes. for some scenes, I would like to have perspective backgrounds that move as the player moves from left to right, such as in this screenshot from Castlevania: symphony of the night:
It's a bit difficult to see here, but the houses in the background are 3d and move as the player moves. Is this kind of thing possible using my method?
Answer by Captain_Dando · Feb 06, 2013 at 02:59 PM
Ok, I've just found an answer to this question on another answer [here][1]:
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."* I've just tested this, it works and it looks like it could have some interesting results. Remember to set the clear flag drop down on your highest cameras to don't clear so that they have no backgrounds. you can effectively render as levels, like in photoshop. I suppose you could also use this to have a 3d GUI if you desired [1]: http://answers.unity3d.com/questions/24628/how-would-i-go-about-constructing-a-layered-scene.html"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.
$$anonymous$$eep in $$anonymous$$d that in some situations it makes more sense to set the clearflags to "depth only". This will clear the depth buffer, so no geometry from the other camera can block parts of your second camera. This is usually used to render the weapon in a FPS game. This ensures that it's always drawn on top of everything else, even when it would intersect with a wall.
Answer by KingKongFu · Feb 06, 2013 at 02:08 PM
Never played casltevania, but I think I get the jist of what you want done. To me it does not look like a 3d model but a really good 2d background, but that being said I never played the game so I dont know for sure.
What you can do is attach the background buildings to the 2d sprint so that it will move with the player. If wanted add a delay or add and minus some x values to move the background a little more dynamically than just the parenting of it to the player which would just be a 1:1 movement ratio.
Hope that can get you on the right track
It's a little hard to see in a still picture, but in motion it definitely looks like it's 3d. I was previously considering using a material which uses a camera as it's texture, and then setting that camera to perspective and putting it's view behind the player and stage, but it looks like that shader is not available in the free version
Also To my knowledge as limited as it is, I think you can only use one perspective for a camera at a time. You can alter this in code but it wont allow you to render in two different perspectives at once.
If you want to try the pro version and see if this would work. $$anonymous$$ake a movie of the background and then apply that movie as a material to a background, I dont know if that would give the effect your looking for though.
Just found the answer on another question, sorry to waste your time, though you have given me a good lead on getting the background to move with the character :) thanks!
not a problem I learned to so its not a waste made me think about it good you found an answer :)
Answer by Nodrius · May 03, 2014 at 12:19 PM
Hi. Captain_Dando you said you found answer in other question, please can you link to it? Im searching for the shame thing
Your answer
Follow this Question
Related Questions
Making a camera semi-orthographic 2 Answers
Camera 2D RPG in perspective 1 Answer
Stairs in 2D 1 Answer
Resizing orthographic camera to fit 2d sprite on screen 1 Answer
Sprite relative position/scale problem with orthographic camera 0 Answers