taping , holding and realising button

hi
I wrote this code :

    if (Input.GetKeyDown(KeyCode.T))
    {
        camera.fieldOfView = 45;
    }

so if player press T in will zoom…
first question is I want right click ( mouse 2) how should I use it?
then I want to do this : on press right mouse click zoom , on releasing it get back to original fieldofview (60)
I searched refrences but I didin’t figured out… how can I do this?

1 Answer

1

u can use this

	if (Input.GetMouseButtonDown(1))
	{
		Camera.mainCamera.fieldOfView = 45;
	}
	
	if (Input.GetMouseButtonUp(1))
	{
		Camera.mainCamera.fieldOfView = 60;
	}

and btw… right click is (mouse 1)

The 'Overrides' dropdown will only appear on the prefab game object that's IN THE SCENE. Don't press the 'open' button! Not the prefab in the Asset folder itself.