Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Zoom in/Zoom Out Camera.

Discussion in 'Scripting' started by sharpg, Mar 28, 2015.

  1. sharpg

    sharpg

    Joined:
    Mar 10, 2015
    Posts:
    150
    hello guys,
    i am working on 2D game using orthographic camera.I am using the following code to decrease the size of camera to Zoom in/out the objects.my object got zoom in perfectly,but i want to control the zoom in speed a bit slow instead of sudden.
    please tell me how can i do that.
    Code (csharp):
    1.  
    2. camera.orthographicSize=4.6;
    3.  
     
  2. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    You'll have to update the camera.orthographicSize value every frame in the Update() method. You can use the Mathf.Lerp method to interpolate the values between the zoomed out value and the zoomed in value.
     
  3. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
  4. sharpg

    sharpg

    Joined:
    Mar 10, 2015
    Posts:
    150
    Thanks All :)