My scroll wheel isn't working at all in unity w/ c#?

Viewed 1719

I'm trying to modify a script that lets the player zoom the camera. Before, scrolling to change the fov worked fine but i wasn't happy with the high fov stretching around the edges so I decided to switch to physical camera movement. For some reason my scroll input doesn't work anymore? This is my code:

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

public class cameraManager : MonoBehaviour
{
    public GameObject cameraAnchor;

    public int cameraState;
    public Transform playerPos;

    public float maxZoomX;
    public float maxZoomY;
    public float zoomSensitivity;

    // Update is called once per frame
    void Update()
    {
        cameraAnchor.transform.position = (playerPos.position + new Vector3(6,10,0)); //camera anchor position relative to player

        if (cameraState == 3){
            Vector3 zoom = Camera.current.transform.position;
            zoom.x += Input.GetAxis("Mouse ScrollWheel") * zoomSensitivity; // changing camera location with scroll wheel
            zoom.y += Input.GetAxis("Mouse ScrollWheel") * zoomSensitivity; // changing camera location with scroll wheel
            zoom.x = Mathf.Clamp(zoom.x, cameraAnchor.transform.position.x, cameraAnchor.transform.position.x + maxZoomX); // clamping zoom
            zoom.y = Mathf.Clamp(zoom.y, cameraAnchor.transform.position.y, cameraAnchor.transform.position.y + maxZoomY); // clamping zoom
            print(Input.GetAxis("Mouse ScrollWheel"));//testing scroll input

            Camera.current.transform.position = zoom; //setting zoom
        }
        else{
            Camera.current.transform.position = cameraAnchor.transform.position; //reset camera anchor if not in 3rd person
        }
        
    }
}

As you can see above, i've tested scrolling with print, which constantly produces a 0, regardless of whether i'm scrolling or not. I've looked at the input settings for the project and everything looks fine there.

Edit: here's a screenshot of my input pageenter image description here

1 Answers

I had this same problem. I loaded up a new project, copied the Mouse ScrollWheel entry from the input settings, and then pasted it into my old project. This resolved the issue. I didn't figure out what caused the issue in the first place.

Related