I’ve already added a GUIText,zoom, zoom text, window script for the display into the GameObject.
I played the scene everything worked fine except that the window does not show the display of the 1b/1b2 camera. I think it has something to do with the zoom script below:
Any solutions? Please Help!
var cam1a : Camera;
var cam1a2 : Camera;
var cam1b : Camera;
var cam1b2 : Camera;
private var baseFOV : float;
function Start () {
baseFOV = cam1a2.fieldOfView;
baseFOV = cam1b2.fieldOfView;
}
function Update ()
{
if (cam1a.enabled == true)
{
if (Input.GetKey("1"))
cam1a2.fieldOfView = baseFOV;
if (Input.GetKey("2"))
cam1a2.fieldOfView = 30;
if (Input.GetKey("3"))
cam1a2.fieldOfView = 15;
if (Input.GetKey("4"))
cam1a2.fieldOfView = 7;
}
if (cam1b.enabled == true)
{
if (Input.GetKey("1"))
cam1b2.fieldOfView = baseFOV;
if (Input.GetKey("2"))
cam1b2.fieldOfView = 30;
if (Input.GetKey("3"))
cam1b2.fieldOfView = 15;
if (Input.GetKey("4"))
cam1b2.fieldOfView = 7;
}
}
Hi there,
just formatted your script to be more easily readable. (to do this in future highlight all your code and press the 101010 button, thanks)
firstly on function Start () you change baseFOV to cam1a2.fieldOfView and then change it immediately to cam1b2.fieldOfView so baseFOV = cam1b2.fieldOfView. if you want to save both fields of view then you should have 2 variables baseFOV1 and baseFOV2.
A major problem I can see is you have forgotten to surround every if statement with {} so you write:
function Update ()
{
if (cam1a.enabled == true)
{
if (Input.GetKey("1")){
cam1a2.fieldOfView = baseFOV;
}
if (Input.GetKey("2")){
cam1a2.fieldOfView = 30;
}
if (Input.GetKey("3")){
cam1a2.fieldOfView = 15;
}
if (Input.GetKey("4")){
cam1a2.fieldOfView = 7;
}
}
also at the moment you have 4 different cameras and from my understanding I thought you would only need 2 however I might be mistaken if your scene is not as I imagined.
I’m guessing you change which camera is enabled in a different script and the problem might be there instead.
you might want to add some debuging or print functions to check if things are getting to places and a t what point your code stops working:
after if (cam1b.enabled == true) {
if (Input.GetKey(“4”)){
cam1b2.fieldOfView = 7;
print(“cam1b is enabled and 7 pressed”)
hope that helps,
Scribe