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

camera zoom....

Discussion in 'Immediate Mode GUI (IMGUI)' started by giancamati, Sep 23, 2010.

  1. giancamati

    giancamati

    Joined:
    Aug 4, 2010
    Posts:
    518
    Hello Unityrs,

    I need to implement the Zoom In/Out for the camera. now, it might be just a matter of changing the FOV, but it's not a real Zoom, or moving the camera along the line towards the target. So I wonder, if there is anything already implemented in Unity camera Class or in Transform which might be helpful.

    Regards,
    Giancarlo
     
  2. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    What context do you mean "zoom in and out." In some situations moving the camera itself is most appropriate, in other situations changing the FOV is the best solution.

    If you mean the kind of zoom you'd see in say, gears of war when you enter iron-sights mode that is accomplished mostly by changing the FOV of the camera, with a slight reposition to taste.

    If you mean the kind of zoom you'd see in a strategy game, that can be accomplished by simply moving the camera around a bit.

    What kind of script are you using to handle the camera right now? As actually accomplishing either method is going to depend quite a bit on your current implementation.
     
  3. burnumd

    burnumd

    Joined:
    May 27, 2008
    Posts:
    367
    I'm likewise unclear on how changing the field of view isn't "real zoom" since it most closely mimics how an actual camera lens works. As for what's in the API to accomplish this task, I'd suggest you get familiar with the documentation, in this case for Camera and Transform, where you'll find Camera.fieldOfView and Transform.Translate().

    Additionally, you might have better luck getting an answer to this question in Support or Scripting, as this isn't really a GUI related question.
     
  4. Sycle

    Sycle

    Joined:
    Nov 24, 2009
    Posts:
    446
    giancamati - changing the FOV is what 'real zoom' is. If you want the camera to approach and retreat from the subject, it's a 'dolly' and is accomplished by moving the camera.

    The best way to do this is going to depend on how your camera is set up, but if you parent it to an empty game object you can adjust the camera's transform.localPosition.z in script and be able to set it to 0 whenever you want to put things back to normal.
     
  5. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Ye I confirm that the "ZOOM" function is just and only a FOV change.
     
  6. giancamati

    giancamati

    Joined:
    Aug 4, 2010
    Posts:
    518
    Guys really thank you so much!