Can't scroll or zoom

Okay so I am following a tutorial about how to make a city game camera controller, And I followed it to the letter but still can`t zoom or turn with the mouse.
error 1 zoom.
It won’t zoom at all both scrollwheel and r/f won’t work.
error 2 turn with camera.
It just turn 1f and stop.

I am new and is trying to learn so probably just missed something!

and if you have any recommendations tell me please =)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
public Transform cameraTransform;
public float normalSpeed;
public float fastSpeed;
public float movementSpeed;
public float movementTime;
public float rotationAmount;
Vector3 zoomAmout;

public Vector3 newPosition;
public Quaternion newRotation;
public Vector3 newZoomAmount;
public Vector3 dragStartPosition;
public Vector3 dragCurrentPosition;
public Vector3 rotateStartPos;
public Vector3 currentRotationPos;

// Start is called before the first frame update
void Start()
{
newPosition = transform.position;
newRotation = transform.rotation;
newZoomAmount = cameraTransform.localPosition;
}

// Update is called once per frame
void Update()
{
HandleMouseInput();
HandleMovementInput();
}

void HandleMovementInput()
{
if(Input.GetKey(KeyCode.LeftShift))
{
movementSpeed = fastSpeed;
}
else
{
movementSpeed = normalSpeed;
}
if(Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
{
newPosition += (transform.forward * movementSpeed);
}
if(Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
{
newPosition += (transform.forward * -movementSpeed);
}
if(Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.LeftArrow))
{
newPosition += (transform.right * movementSpeed);
}
if(Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.RightArrow))
{
newPosition += (transform.right * -movementSpeed);
}
if(Input.GetKey(KeyCode.Q))
{
newRotation *= Quaternion.Euler(Vector3.up * rotationAmount);
}
if(Input.GetKey(KeyCode.E))
{
newRotation *= Quaternion.Euler(Vector3.up * -rotationAmount);
}
if(Input.GetKey(KeyCode.R))
{
newZoomAmount += zoomAmout;
}
if(Input.GetKey(KeyCode.F))
{
newZoomAmount -= zoomAmout;
}
transform.position = Vector3.Lerp(transform.position, newPosition, Time.deltaTime * movementTime);
transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * movementTime);
cameraTransform.localPosition = Vector3.Lerp(cameraTransform.localPosition, newZoomAmount, Time.deltaTime * movementTime);

}
void HandleMouseInput()
{
if(Input.mouseScrollDelta.y != 0)
{
newZoomAmount += Input.mouseScrollDelta.y * zoomAmout;
}
if(Input.GetMouseButtonDown(0))
{
Plane plane = new Plane(Vector3.up, Vector3.zero);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

float entry;

if(plane.Raycast(ray, out entry))
{
dragStartPosition = ray.GetPoint(entry);
}
}
if(Input.GetMouseButton(0))
{
Plane plane = new Plane(Vector3.up, Vector3.zero);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

float entry;

if(plane.Raycast(ray, out entry))
{
dragCurrentPosition = ray.GetPoint(entry);

newPosition = transform.position + dragStartPosition - dragCurrentPosition;
}
}

if(Input.GetMouseButtonDown(2))
{
rotateStartPos = Input.mousePosition;
}
if(Input.GetMouseButton(2))
{
currentRotationPos = Input.mousePosition;

Vector3 diffrence = rotateStartPos - currentRotationPos;
rotateStartPos = currentRotationPos;

newRotation = Quaternion.Euler(Vector3.up * (-diffrence.x/5));
}

}

}

Looking at a wall of code is not always helpful. You have to find out what it is actually doing at runtime.

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is
  • you’re getting an error or warning and you haven’t noticed it in the console window

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: How To - Capturing Device Logs on iOS or this answer for Android: How To - Capturing Device Logs on Android

Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

You must find a way to get the information you need in order to reason about what the problem is.