Disabling Camera

Right, so all I am trying to do is make a script, where my player can interact with a bed, click a certain key and then go to sleep, that is the cameras crossfading and disabling. After say about 20 seconds, I want the cameras to cross fade on again. The reson I sade Cameras, is because I have two of them, one under the Main Camera. The point indoing this was to prevent my arms, attached to the player, from clipping through walls. So to sum it all up, all I want is a script that can enable me to interact with a bed object, go to sleep, i.e. camera disabling, and oncle again waking up. Here is my script so far, if any of you guys have a better one, please give it:smile::

var theBed : Transform;
var camera01 = Camera;
var camera02 = Camera;
var PlayerisSleep = false;
private var drawGUI = false;

function Update ()
{
if(drawGUI == true Input.GetKeyDown(KeyCode.E))
{
PlayerisSleep = true;
GoSleep();
}
}

function OnTriggerEnter (theCollider : Collider)
{
if(theCollider.tag == “Player”)
{
drawGUI = true;
}
}

function OnTriggerExit (theCollider : Collider)
{
if(theCollider.tag == “Player”)
{
drawGUI = false;
}
}

function OnGUI ()
{
if(drawGUI == true)
{
GUI.Box (Rect (Screen.width*0.5-51, 200, 120, 22),“Press ‘E’ to Sleep”);
}
}

function GoSleep ()
{
if(PlayerisSleep == true)
{
camera01.enabled = false;
camera02.enabled = false;
yield WaitForSeconds (20);
camera01.enabled = true;
camera02.enabled = true;
}
PlayerisSleep = false;
}

There are many ways you can “fade a camera out” - a lot depends on your context. You can use GUI to do most of the work - how to fade in/out a scene? - Questions & Answers - Unity Discussions

I would use iTween or some other simple tween engine to just tween your alpha value, and have GUI.color alpha set to the value you want.

Thanks Bro