Full screen camera missing?

Hello everybody,

I have just started out with Unity and I am absolutely loving it, however, I stumbled on a pretty simple problem (I hope) that I cannot solve on my own. This is the situation:

I am making a first person shooter which will have x number of weapons. Among those, I have a rocket launcher. When the user holds the right mouse button, the Main Camera should switch to the rocket launcher camera.

Whenever I hold the right mouse button, the screen fills with the following message: “missing full screen camera”. This is my current code for the camera switching:

public Camera playerCam;
public Camera rocketLauncherCam;

private void Start()
{
    playerCam.enabled = true;
    rocketLauncherCam.enabled = false;
}

private void Update()
{
    if (Input.GetKey(KeyCode.Mouse1))
    {
        playerCam.enabled = false;
        rocketLauncherCam.enabled = true;
    }
    else
    {
        playerCam.enabled = true;
        rocketLauncherCam.enabled = false;
    }
}

I cannot figure out what I did wrong. Enable one camera while disabling the other one, seemed like the way to go.

I hope this problem is easy to fix.

Thanks in advance and I really appreciate the time you take when you write an answer. Since the solution cannot be that hard, I do not ask for a large explanation. Just a quick overview, otherwise it would take too long (and I learn more by analyzing code).

Have a nice day,

Tahar

I guess you didn’t asigned:

public Camera playerCam;
public Camera rocketLauncherCam;

Maybe use this instead.

public Camera playerCam;
public Camera rocketLauncherCam;

private void Start()
{
playerCam = GameObject.Find(“playerCam”).GetComponent();
rocketLauncherCam = GameObject.Find(“LauncherCam”).GetComponent();
playerCam.enabled = true;
rocketLauncherCam.enabled = false;
}

private void Update()
{
if (Input.GetKey(KeyCode.Mouse1))
{
playerCam.enabled = false;
rocketLauncherCam.enabled = true;
}
else
{
playerCam.enabled = true;
rocketLauncherCam.enabled = false;
}
}
,I guess Unity doesn’t use

public Camera playerCam;
public Camera rocketLauncherCam;

because you didn’t initialized them right. Use this instead.

public Camera playerCam;
public Camera rocketLauncherCam;

private void Start()
{
GameObject hand;
playerCam.enabled = true;
rocketLauncherCam.enabled = false;
}

private void Update()
{
if (Input.GetKey(KeyCode.Mouse1))
{
playerCam.enabled = false;
rocketLauncherCam.enabled = true;
}
else
{
playerCam.enabled = true;
rocketLauncherCam.enabled = false;
}
}

I’m not sure about this, but try switching the tag from your rocket launcher camera to MainCamera. I guess there should always be a camera with the MainCamera tag since some things depend on Camera.main.

Hello everybody,

Thanks a lot for the responses, but I have already found the solution. I was being incredibly silly! I disabled the gun camera… I re-enabled it and there it was! Everything is working as it is supposed to.

Have a nice day!

Tahar