Zoom camera
I want to make a button closer to the camera it works without the button but with the button it doesn't work
public int speed;
bool IsZoom;
void Start()
{
IsZoom = false;
}
void Update () {
transform.Rotate(0, speed * Time.deltaTime,0);
if (GetComponent<Camera>().fieldOfView >= 20 && GetComponent<Camera>().fieldOfView <= 50 && IsZoom == true)
GetComponent<Camera>().fieldOfView = Mathf.Lerp(GetComponent<Camera>().fieldOfView, 10, Time.deltaTime * 5);
}
public void Zoom()
{
Debug.Log("dfff");
IsZoom = true;
if (IsZoom == true)
IsZoom = false;
}
I changed the code to it and it still doesn't work public void Zoom() { if (IsZoom == false) IsZoom = true; else IsZoom = false; }
Answer by JonPQ · Aug 20, 2019 at 03:57 PM
your Zoom() function does no appear to do anything.... if zoom is false it does nothing. if its true, it turns it to false... so isZoom will always be false...
why not do something in Update() like... if (input.buttonPressed(keyCode.Z)) isZ0om =true; else isZoom = false;
or do...
if (input.buttonPressed(keyCode.Z))
isZoom = true;
if (input.buttonUp(keyCode.Z))
isZoom = false;
Your answer
Follow this Question
Related Questions
Clamping when Zoom changes? 0 Answers
Problems with rotation after zoom (camera like Sketchfab) 0 Answers
Exponential Zoom Equation Not Working 0 Answers
Render to minimap on command 1 Answer
Third Person Shooter Controller 0 Answers