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 181 150 166

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

3 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 184 158 182

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

No estoy muy seguro de lo que quieres decir ... Tambin habla usted Ingls? Tengo que usar traductor Google para escribir esto.

Dec 08, 2010 at 08:05 PM 3dDude
(comments are locked)
10|3000 characters needed characters left

HI, Create a java script MonoDev and put those codes after that attached to Main Camera in Hierarchy Layout.Camera Projection to be perspective only.

Thanks Ram

more ▼

answered Aug 28 at 06:00 AM

ramp gravatar image

ramp
0 3 9 17

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

There are two ways to implement zoom method. One is changing the field of view of camera and the other is changing z position of camera. Which way is better?

more ▼

answered Sep 03 at 09:47 AM

dttngan91 gravatar image

dttngan91
1

(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:

x4921
x270

asked: Jun 26, 2010 at 01:28 PM

Seen: 21059 times

Last Updated: Sep 03 at 09:47 AM