How to use background/overlay scenes?

Hi,

I’m a new Unity user.

Here are my questions :
1. Is it possible to use background/overlay scenes?
I have tried to get the expected result by using layers and several cameras, but I was not satisfied with it.
I don’t like the fact that my character (main layer) can collide objects that are on the background layer.
I don’t want to delete the colliders because I need to keep collisions between objects that are in the bg layer.

If that solution (background scenes) exists, how can I control -from the main scene- my camera that is on the background scene?

1. I use a script so my camera follows my main character.
The problem is that my camera is shaking when the main character is moving too fast.

Here is my script :

``````var master_obj : Transform;
var moveSpeedX : float = 1.0; //degrees per unit of input
var moveSpeedY : float = 1.0; //degrees per unit of input
var moveSpeedZ : float = 1.0; //degrees per unit of input
var moveDamping : float = 20.0;
private var initPos : Vector3;

function Start () {
if (master_obj)
initPos= transform.position - master_obj.position;
else
return;
}

function Update () {
if (master_obj){
//Move this
if (moveSpeedX!=0)
endPosX = initPos.x + master_obj.position.x * moveSpeedX;

if (moveSpeedY!=0)
endPosY = initPos.y + master_obj.position.y * moveSpeedY;

if (moveSpeedZ!=0)
endPosZ = initPos.z + master_obj.position.z * moveSpeedZ;

endPos = Vector3(endPosX, endPosY, endPosZ);
transform.position = Vector3.Lerp(transform.position, endPos, moveDamping * Time.deltaTime);
}
else
return;
}
``````

Do you know how to solve that shaking problem?
I have read the forums and Unityanswers (like, lowering Fixed Timestep / Time scale) but it didn’t work and it seems to be a trick more than a solution.

Thank you!

If you’re using Unity3 you can disable collisions between layers (Edit->Project Settings->Physics).

Otherwise there’s always Physics.IgnoreCollision( Collider a, Collider b ), which you can run on player startup to ignore all background objects.

The shakycam is probably caused by the camera script or by whatever is moving master_obj.

Hi Vicenti,

The solution you provided works very well, and I get the result I expected.

However, I would like to know if scenes can also be set as background/overlay?
Building scenes and use it as backgrounds could also be very convenient for my needs.

I don’t think you can use separate scenes, but you can build a separate area in your scene and have a second camera render it. Have your main camera’s clear flags set to “Don’t Clear”, and your secondary camera should show up behind whatever the main camera sees. Set the main camera’s depth higher than the background camera’s depth and you should be good to go.

I only played with this for a few minutes myself, but I was able to get an overlay screen working.

Thanks to your previous advice, I got overlay and background layers to work, and the result is already good enough (for a beginner).

However, separate scenes would give a better control on Render settings per scene : Ambient light, fog, etc…
There should be other settings available only through the combination of several scenes.
So, in some of the projects I’m working on, a combination of layers is not the same as a combination of scenes.

Where can I get an answer from a Unity team member, to know if using background/overlay scenes is possible or not?

Using separate cameras is a good workaround, but it isn’t possible to use one scene as the background for another in Unity.

I see… thank you. It would be great, though!

How would you simulate multi fogs? With shaders?

You could create a plane that’s fully opaque at the bottom and fully opaque at the top, and move it down as the player approaches it and up as the player moves away.

I think.

I’ve never tried multiple fogs, myself, but that’s what I’d try first.