x


Camera Zoom in Script....

Can someone tell me how to do a camera zoom-in script? So my view will start zoomed out then it will zoom in and stay that way just to give some view of the surroundings...

Thanks a bunch! :)

more ▼

asked Jun 26, 2010 at 01:28 PM

MikezNesh gravatar image

MikezNesh
993 180 142 163

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

well i don't know what controls that you want but if you want to zoom in you can change the cameras field of view (E,G)

var zoom : int = 20;
var normal : int = 60;
var smooth : float = 5;
private var isZoomed = false;
function Update () {
     if(Input.GetKeyDown("z")){
          isZoomed = !isZoomed; 
     }

     if(isZoomed == true){
          camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,zoom,Time.deltaTime*smooth);
     }
     else{
        camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,normal,Time.deltaTime*smooth);
     }
}

Edit added smooth speed to the movement.

hope this helps! :)

more ▼

answered Jun 26, 2010 at 03:16 PM

3dDude gravatar image

3dDude
2.8k 183 151 178

Could you tell me how to add speed to the camera?

Jun 27, 2010 at 12:27 AM MikezNesh

made a edit :)

Jun 27, 2010 at 01:12 AM 3dDude

How about without input? Could you tell me how to zoom in from the very beginning?

Jun 27, 2010 at 09:17 AM MikezNesh

well if you wanted to start with it zoomed just make var isZoomed = false; and make it var isZoomed = true;

but if you wanted to always be zoomed i think you can change the camera.fieldOfView if you select the camera and just change the value in the inspector

Jun 27, 2010 at 01:14 PM 3dDude

este codigo esta al reves verdad?

Dec 08, 2010 at 07:48 PM raul corrales
(comments are locked)
10|3000 characters needed characters left

where i put those codes ?

more ▼

answered Dec 15, 2013 at 02:40 AM

breezanity_28 gravatar image

breezanity_28
0 21

The camera.

Dec 15, 2013 at 02:45 AM Commander Quackers
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4740
x262

asked: Jun 26, 2010 at 01:28 PM

Seen: 20169 times

Last Updated: Dec 15, 2013 at 02:45 AM