- Home /
Camera Panning in the context of a game with prerendered backgrounds
Hi there,
A bit of background: Since I miss the old school RPG from the PSX (FFVII/IX, Chrono Cross, Parasite Eve) I've decided to give it a go myself on Unity and learn a bit more about this rendering technique. Basically those types of games include a 2D prerendered background mixed with 3D elements (characters, interactive objects...)
So far so good, I managed to find a way to match a camera from 3dsmax with the one from Unity so that the 3d scene in Unity fits perfectly with the background. With the use of a very simple shader, and a modification of the rendering order, I can have my character walking behind 2D elements from the rendered background. And finally I got my controls working relatively to my camera angle. Brilliant.
Hopefully a little demo will come along the way soon enough.
Now my problem is about camera panning. Since all this can work only with a fixed rendered background, it's absolutely crucial to not move the camera at all in the 3D scene in Unity. However some of the games I mentioned above found their way around by "dragging" the scene as you would drag a 2D image. So you would drag both the background and the 3d scene together in the required direction.
Would this actually be possible in Unity? Would that mean that what the 3D camera can see needs to be bigger than the size of the screen?
At first I thought it would just be about playing around with the normalized viewport rectangle. But I don't think this functionality fits the purpose of this feature.
Does a projection matrix needs to be involved there?
Here is an example to illustrate what I would like to achieve: http://youtu.be/8khIPlWbixI?t=11m2s
Any help would be well appreciated. Thanks.
EDIT: This looks more like an appropriate example http://youtu.be/8khIPlWbixI?t=15m50s We can clearly see here that the camera is not getting any transform value changed. Instead, the whole scene is moved with a vertical offset, both 2D background and 3D elements.
Answer by tr0ma · May 10, 2013 at 01:11 AM
I have provided a possible solution here: http://answers.unity3d.com/answers/453367/view.html
Can you provide more information or some code snippets on how you accomplished this? $$anonymous$$y thought is that you might be able to create your own projection matrix to view an off-center portion of the 3D scene (http://docs.unity3d.com/Documentation/ScriptReference/Camera-projection$$anonymous$$atrix.html)
For example, if your device screen is 640x480 and your 2D pre-rendered background is 1280x960 then couldn't you view the bottom left of the 3D scene by using (0, 0) -> (0.5,0.5)?
Your answer
![](https://koobas.hobune.stream/wayback/20220613101748im_/https://answers.unity.com/themes/thub/images/avi.jpg)