how to code a zoomable/resizable camera in game?

Hello! I’m currently coding the (turn based) combat in my game, but I can’t adjust the camera at all.

I’d like to include the option to manually zoom in and out of the camera while I’m in battle , but also have the camera auto adjust while in the overworld.

How can I implement this in my game

Here its how you implement the zoom in and zoom out to your game :slight_smile:

//This is to get the mouse wheel
public float zoomSpeed = YourValueHere;
float scroll = Input.GetAxis("Mouse ScrollWheel");

By accessing position you get a copy of the Vector3.
Use this

transform.Translate(0,scroll*zoomSpeed,scroll*zoomSpeed,Space.World);

After that you can normally use this . Note: Please don’t use translate on camera because it is slow so better play with the fov.

camera.fieldOfView *= scroll*zoomSpeed;

delete the line

  public scroll;

if you want to make it public, then just add the keyword “public” to the front of this line:

float scroll = Input.GetAxis("Mouse ScrollWheel");