Question by
HyblockerDevelopment · Aug 26, 2016 at 04:44 PM ·
c#cameraerror
Camera Toggling Error
Hi there
I'm trying to make a script to toggle between cameras, but unity is bringing up the following:
(5,23): warning CS0108: `CamerChange.camera' hides inherited member `UnityEngine.Component.camera'. Use the new keyword if hiding was intended
Please help me, i'm a N00b at scripting :( Below is my code:
using UnityEngine;
using System.Collections;
public class CamerChange : MonoBehaviour {
public Camera camera;
public Camera camera2;
public Camera camera3;
public KeyCode ChangeCameraKey;
void Start(){
camera.enabled = true;
camera2.enabled = false;
camera3.enabled = false;
}
void Update(){
int usingcamera = 0; //this initializes a camera control variable
//This toggles between cameras
if(Input.GetKeyUp(ChangeCameraKey)){
if (usingcamera == 1) {
camera.enabled = true;
camera2.enabled = false;
camera3.enabled = false;
usingcamera = 2;//goes to camera
}
if (usingcamera == 2) {
camera.enabled = false;
camera2.enabled = true;
camera3.enabled = false;
usingcamera = 3;//goes to camera2
}
if (usingcamera == 3) {
camera.enabled = false;
camera2.enabled = false;
camera3.enabled = true;
usingcamera = 1;//goes to camera3
}
}
}
}
Comment
Best Answer
Answer by DavidWatts · Aug 26, 2016 at 05:03 PM
the name camera was used in earlier versions and now comes up as a warning whenever you use the name camera so you know to update the code. just use a different name and the warning will go away
Your answer
Follow this Question
Related Questions
How to do a wall jump? i am very novice 0 Answers
how to connect external display to second camera in unity? 0 Answers
i am trying to work with wheel collides and i am having some problems 0 Answers
What this error? 0 Answers
Compile Error 0 Answers