- Home /
Question by
Grizzly · Mar 18, 2015 at 08:17 PM ·
unity 5camerajavascript
Camera problem ,Unity 5
I am trying to fix errors in one of the scripts I transfered from Unity 4 to Unity 5:
Here it is:
public var FOVIN : float = 35;
public var FOVSpeed : float = 5;
public var Aim : boolean = false;
public var DeffFOV : float;
public var Cam : Camera;
function Start(){
DeffFOV = GetComponent.Camera.fieldOfView;
}
function Update () {
if( Input.GetMouseButtonDown(1)){
Aim = true;
}
if( Input.GetMouseButtonUp(1)){
Aim = false;
}
if( Aim){
GetComponent.Camera.fieldOfView = Mathf.Lerp( GetComponent.Camera.fieldOfView, FOVIN, FOVSpeed * Time.deltaTime);
}
if( !Aim){
GetComponent.Camera.fieldOfView = Mathf.Lerp( GetComponent.Camera.fieldOfView, DeffFOV, FOVSpeed * Time.deltaTime);
}
}
Its giving me problems with Camera part ,I am not sure I am using the "get component" right here ,I tryed the "GetComponent().fieldOfView" but it still gave errors ,this way I posted up in the code part lets me get into game mode but I get null reference error.... Help pls
Comment
Best Answer
Answer by Grizzly · Mar 18, 2015 at 08:39 PM
Nevermind , I forgot to add "." after GetComponent , solved.
Your answer
Follow this Question
Related Questions
what is the newer version of this piece of code? -1 Answers
Framing the camera to all objects in scene 0 Answers
Rotating Main Camera 1 Answer
How to fade in/out the view of a specific Camera? 2 Answers
Click on collider to rotate camera 1 Answer