Zoom with camera.fieldOfView does not work?

hey guys, this is my first post, and i’m german, so pls be considerate…

i’m trying to make a zoom funktion with a script which changes the field of view of the camera, but it doesn’t works!
it should zoom in (with right mouse button) and when not pressed, it should zoom out. here the code (dont know how to post codes correctly):

if (Input.GetMouseButtonDown(1) camera.fieldOfView < 60 camera.fieldOfView > 50)
{
camera.fieldOfView = camera.fieldOfView+1;
}
else if (camera.fieldOfView < 60 camera.fieldOfView > 50)
{
camera.fieldOfView = camera.fieldOfView-1;
}

Sooner or later camera.fieldOfView+1 will make it equal to 60 and that doesn’t fit any of your conditions.
I guess you need “<= 60” in your else if block.

You could try this, play around a bit with the values or change GetMouseButton to GetMouseButtonDown to see what happens.

By the way, I never did this before but it seems you have to lower the field of view in order to get the zooming effect.

		if (Input.GetMouseButton(1))
		{
			camera.fieldOfView -= 1;
			
			if (camera.fieldOfView < 50)
			{
				camera.fieldOfView = 50;
			}			
		}
		
		else 
		{
			camera.fieldOfView += 1;
			
			if (camera.fieldOfView > 60)
			{
				camera.fieldOfView = 60;
			}
		}

yeah i changed the + and -, but that was not the problem, the problem is that Input.GetMouseButton(1) everytime false is… ( btw my mouse is not broken xD)

thx worked (dont know whats the problem with my code -.-)