Cannot Convert boolean to UnityEngine.GameObject
Hey guys,
Im trying to switch views in game from the Main Camera to the 1st Person Controller, I have it set up so that the Main Camera is Enabled at the start and the 1st Person is Disabled, But I Get This Error Cannot convert 'boolean' to 'UnityEngine.GameObject'. here is my simple script,
#pragma strict
var mainCamera : Camera;
var firstPerson : GameObject;
function Start ()
{
mainCamera.enabled = true;
firstPerson.SetActive(false);
}
function OnMouseDown ()
{
ChangeCamera();
}
function ChangeCamera()
{
mainCamera.enabled = !mainCamera.enabled;
firstPerson = !firstPerson.SetActive(!true);
}
im getting the error on Line 20... firstPerson = !firstPerson.SetActive(!true);
Any help would be much appreciated, Thank You.
Answer by Winterblood · Apr 20, 2016 at 03:35 PM
Try this:
function ChangeCamera()
{
mainCamera.enabled = !mainCamera.enabled;
firstPerson.SetActive( !mainCamera.enabled );
}
You want to set your firstPerson activeness to the opposite of your mainCamera activeness. So if the mainCamera is ON, firstPerson should be OFF.
Im just starting out program$$anonymous$$g, so a lot of things confuse me, but your answer worked great, Thank You.
Your answer
Follow this Question
Related Questions
How to access camera Dont Clear in camera clear flags using c# 1 Answer
UI element attached to Camera Coordinates 2 Answers
Camera rotate X degree based on player rotate 0 Answers
Stuttering nav Mesh Agent movement when i move the character 0 Answers
How to move camera with Input.GetAxis() and my camera view direction?!! 1 Answer