Hi forum, I was reading about lerping. I have a camera that just allows for zooming a bit in and out, between a minimum and a maximum value, using an orthographic camera and jumping in increments of 0.5 per time the mousewheel is turned, this obviously gives some jerky jumps on the camera, and I figured I would try to implement some slerping, for that extra two cent effect!
Below is my current working camera script. What I tried for adding mathf slerping was to set a new variable, as the final zoom amount, then check if the camera isn’t at that point, and if it isn’t slerp over, say, two seconds towards that. But it keeps failing, in either syntax or unity engine errors, anyone up for filling in the blanks, greatly appreciated.
private var Camera_ZoomMinimum : float = 0.5;
private var Camera_ZoomMaximum : float = 3.0;
function Update ()
{
if(Input.GetAxis("Mouse ScrollWheel") < 0)
{
if(camera.orthographicSize+0.5 >= 3.0)
{
camera.orthographicSize = 3.0;
}
else
{
camera.orthographicSize = camera.orthographicSize + 0.5;
}
}
if(Input.GetAxis("Mouse ScrollWheel") > 0)
{
if(camera.orthographicSize-0.5 <= 0.5)
{
camera.orthographicSize = 0.5;
}
else
{
camera.orthographicSize = camera.orthographicSize - 0.5;
}
}
}