I am creating endless running game. I want to zoom camera when player dies to the player. I have tried using camera.FieldOfView, but it does not work. Is there another way to zoom In camera to the object when particular condition becomes true. Thanks in advance.

  • \$\begingroup\$ For the trick you can use smooth camera follow when your player dies \$\endgroup\$ – Hamza Hasan Feb 23 '16 at 6:20
  • \$\begingroup\$ can you explain further? \$\endgroup\$ – Piina Kansara Feb 23 '16 at 6:23

As I said the trick you can use is to just activate Smooth Camera Follow when your player dies. You can take the script for Smooth Follow from this answer.


  • Attach it to camera.
  • Play and properly configure it, as you want.
  • Disable the script.
  • Enable it when your player dies.

Note: This is for 3D environment, as you are trying to change FOV of camera, which is applicable in perspective view. If you are developing a 2D game then let me know.

Update: As you already have camera follow script for your 2D game, just change the Camera.main.orthographicSize.

Camera.main.orthographicSize = 1;

You can also make a coroutine for some smooth effect

IEnumerator ZoomIn ()
        while (Camera.main.orthographicSize > 1) {
            yield return new WaitForSeconds (0.01f);
            Camera.main.orthographicSize -= 0.1f;

Just call StartCoroutine ("ZoomIn"); once when your player dies.

  • \$\begingroup\$ Then FOV is obviously not gonna work :) I'm outside for a break, give me 10 minutes:) \$\endgroup\$ – Hamza Hasan Feb 23 '16 at 6:41
  • \$\begingroup\$ Wait a minute, of you are developing an endless runner then you already must have a camera follow script? Right? \$\endgroup\$ – Hamza Hasan Feb 23 '16 at 6:43
  • \$\begingroup\$ Then change the size attribute instead of field of view \$\endgroup\$ – Hamza Hasan Feb 23 '16 at 6:48
  • \$\begingroup\$ orthographicSize?? \$\endgroup\$ – Hamza Hasan Feb 23 '16 at 6:51
  • 1
    \$\begingroup\$ This made me laugh. \$\endgroup\$ – jgallant Feb 23 '16 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.