I am trying to make it so that when you scroll the camera 'zooms' by moving up or down for one of my projects. but whenever I run it I get no errors but I cant move it at all. Here is my code.
using UnityEngine;
public class CameraMovement : MonoBehaviour
{
public float MaxZoom;
public float MinZoom;
public float ZoomSpeed;
Vector3 p = new Vector3(0,0,0);
// Start is called before the first frame update
void Start()
{
Vector3 p = transform.position;
p.y = MaxZoom;
}
// Update is called once per frame
void Update()
{
Debug.Log(Input.mouseScrollDelta.y);
p.y += Input.mouseScrollDelta.y * ZoomSpeed;
if (p.y > MinZoom)
{
p.y = MinZoom;
}
if (p.y < MaxZoom)
{
p.y = MaxZoom;
}
}
}