3d collision problem

I’m a beginner trying to make a game where you are a 2d character in a 3d world who can move their plane throughout the Z axis to solve puzzles. I’m having a problem where I want the hitbox that i added to the camera to not be able to go through objects. Basically i want to move my plane unless i will go in an object. here;s my code.

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.UIElements;

public class CameraManager : MonoBehaviour
{
    bool colliding = false;

    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            if (!colliding)
            {
                transform.position += new Vector3(0, 0, 0.01f);
            }

        }

        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            if (!colliding)
            {
                transform.position += new Vector3(0, 0, -0.01f);
            }
        }
    }

    void OnCollisionEnter(Collision collision)
    {
        colliding = true;
        Debug.Log("hello");
    }

    void OnCollisionExit(Collision collision)
    {
        colliding = false;
    }
}

Im also getting errors on the collision enter and exit that they are unused which also makes no sense.