Unfortunately there are many ways to do what your asking and from the info you have here it's very hard to tell what's going on. We're missing a lot of information.
It appears to me that
onObjectsClick(event) is not an "Updated" but a single frame function.
It appears to me that you are using lerp in a way that it's not really designed for. Don't get me wrong, if it works then awesome. But lerp is typically a value between 0% and 100%. So, you need to get the percentage of where you want it to be along its trip. Here, take a look at what I have here written in C#. Plug it into a fresh script and drag the script onto the camera. press the "M" and you'll see it lerps. You can adapt this to "slerp" or Spherical Lerp very easily. slerp is a lerp on a sign wave function. Looks smoother but fundamentally the same thing. I hope this helps you learn about Lerp and how it's supposed to work.
A static start point.
A static end point.
A static start time.
A static length (of time or anything really).
If you update any of these values while it's lerping you'll likely end up with an infinite lerp (which can look smooth sometimes) or just a quick pop from one place to another. Like I said, use it how you like. What ever gets the effect you're looking for but this is likely one of the more optimal (performance wise) ways to use lerp.
public class CameraLerp : MonoBehaviour
public Vector3 camPosStart;
public Vector3 camPosTarget;
public float lerpStartTime;
public float lerpTimeLength = 5f;
public bool lerping;
private void Update()
private void MoveCamera()
//every time you press m the camera will move 10 on the z axis (world space).
//This will work for any vector3's. Just input the start time as Time.time and the
//startPos as the currect Vector3's value. The target as the target value
lerpStartTime = Time.time;
camPosStart = Camera.main.transform.position;
camPosTarget += new Vector3(0, 0, 10f); //this should be set to what ever you want the camera position to lerp to.
lerping = true;
if (Camera.main.transform.position == camPosTarget)
lerping = false;
Camera.main.transform.position = Vec3Lerp(camPosStart, camPosTarget, lerpStartTime, lerpTimeLength);
private Vector3 Vec3Lerp(Vector3 start, Vector3 target, float startTime, float timeLength)
float timeLerping = Time.time - startTime;
float percentageComplete = timeLerping / timeLength;
Vector3 result = Vector3.Lerp(start, target, percentageComplete);