How to zoom camera relative to Camera view with mouse scroll?

Hello,

Im trying to zoom my camera (that is a child of a gameobject) from and to that object. I do not want it to change the FOV.


What I looked at:

transform.position = transform.forward * scrollwheelspeed
transform.position = transform.transformDirection(vector3).

If anyone can help me out I would appreciate that a lot.

for now I am cheating by individually tweaking the localposition of Y and Z value of the Camera, but that doesn’t look smooth/nice.

Nobody any directions I can look at to solve this?

You can change the Field Of View of the camera by using the following code…

public void Update ()
{
	float changeValue = Input.GetAxis("Your Axis Name Here...");
	
	Camera.main.fieldOfView += changeValue;
	
	// Optional if you don't want freaky effects...
	Camera.main.fieldOfView = Mathf.Clamp(Camera.main.fieldOfView, 5f, 120f);
}