How do I move a Camera Y position with the Mouse ScrollWheel?

At the moment I've sorted my script to zoom into its target with the Mouse ScrollWheel, but I've been trying to edit the script to move the camera's Y position at the same time as zooming in.

distance += Input.GetAxis("Mouse ScrollWheel")*distance;
distance = Mathf.Clamp(distance, minDistance, maxDistance);

I should add this is a snippet of my modified MouseLook.js (comes with unity)

My attempts have been:

var vert : float = Input.GetAxis("Mouse ScrollWheel");
transform.Translate(Vector3(0, vert, 0) * Time.deltaTime);

But for some reason, even if I attached my attempt to an empty GameObject parenting the camera, the Y positon of the camera is always locked into place.

Also I would like the camera movement on zooming and changing Y to ease into there positions.

Please help! - thanks

Hi,

Your code is ok, you might have actually an error elsewhere.

This is the full script I am using and it works very well. I have added a speed variable, because I can see several potential problem:

1:either the scroll input setting has been changed and too small to see any effect, hence the speed, so that you can adjust to see if indeed this is the input settings that is wrong. 2: You are using the script in the wrong handler ( I always do the mistake and write OnUpdate()... that doesn't work very well... :) )

public var speed:float = 2;

function Update(){

var vert : float = Input.GetAxis("Mouse ScrollWheel");
transform.Translate(Vector3(0, vert, 0) * Time.deltaTime * speed);

}

Hope that helps,

Jean