- Home /
Question by
robert97mc · Jan 27, 2014 at 12:18 AM ·
gameaimfov
how to change FoV
so when i try to change fov with script i get some null error, here's the script:
var mainCam : Camera;
var normalPos : Vector3;
var aimPos : Vector3;
var weapon : GameObject;
function Start()
{
mainCam = Camera.main;
}
function Update()
{
if(Input.GetButton("Fire2"))
{
weapon.transform.localPosition = Vector3.Lerp(weapon.transform.localPosition, aimPos, Time.deltaTime * 8);
mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, 45, Time.deltaTime * 10);
}
else
{
weapon.transform.localPosition = Vector3.Lerp(weapon.transform.localPosition, normalPos, Time.deltaTime * 8);
mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, 60, Time.deltaTime * 10);
}
}
Comment
Answer by CostelloNicho · Jan 27, 2014 at 12:22 AM
This is just a guess, but make sure that the Camera in your scene is tagged as your mainCamera. You can change the tag by selecting the camera and clicking the tag drop down menu in the inspector.
Ps. I can't really give you much more of an answer without seeing the error and a more descriptive question.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Loadlevel can't see each other. 2 Answers
I do a game for the school 1 Answer
How do I create a pause button? 2 Answers
Plugin Container for Firefox/Unity Web Player crash whenever I try to load Dead Trigger 2 0 Answers