Changing Camera Variables

I’d like to find a camera that is tagged “MainCamera” and change some of the values for the variables in the “SmoothFollow” Script.

However, this isn’t working as I planned. I keep getting an error that says the camera object isn’t referenced when I try to manipulate the vars. Here is the code I have.

**var currentcamera:GameObject; var currentcamerainfo; if(Input.GetButtonDown("CamButton"))// { currentcamerainfo.Distance+=1; currentcamerainfo.Height+=1.5; }**

This is all set to be setup during the awaken function. Which is this segment of code:

**function Awake() { currentcamera=GameObject.FindGameObjectWithTag("MainCamera"); currentcamerainfo=currentcamera.GetComponent("SmoothFollow.js"); }**

Does anyone know why the camera isn’t being assigned to the current camera variable?

Change

var currentcamera:GameObject;

to

var currentcamera:Camera;

But instead of doing it like that… you can use Camera.main instead to always reference the first enabled camera in your scene tagged with MainCamera.

So you could change your Awake function to be…

currentcamerainfo = Camera.main.GetComponent("SmoothFollow.js");

have you tried Camera.main.gameObject.GetComponent(Transform) ?

sorry, instead of transform, point to your “SmoothFollow” (oops… copy paste rush)