1. Unity 5.6 is now released.
    Dismiss Notice
  2. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  3. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  4. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  5. The launcher is currently pulling earlier versions of the content packages which may have errors, see post.
    Dismiss Notice
  6. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  7. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice

camera zoom....

Discussion in 'Extensions & OnGUI' 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:
    820
    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. megmaltese

    megmaltese

    Joined:
    Mar 19, 2009
    Posts:
    1,940
    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!