camera zoom....

Discussion in 'UnityGUI' started by giancamati, Sep 23, 2010.

  1. giancamati

    giancamati

    Member

    Joined:
    Aug 4, 2010
    Messages:
    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

    Member

    Joined:
    Nov 4, 2009
    Messages:
    805
    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

    New Member

    Joined:
    May 27, 2008
    Messages:
    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

    New Member

    Joined:
    Nov 24, 2009
    Messages:
    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. megmaltese

    megmaltese

    Member

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

    giancamati

    Member

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