I have a button in my scene, a main camera and an empty game object.
Whenever I click on that button my camera should slowly lerp to that empty game object's position.
My camera is lerping to that position, which is fine, but the problem is that I have to click multiple times on that button until my camera reach its position. So is there a way to move my camera to game object's position using a single click on that button?
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TransitionCAM : MonoBehaviour {
public Transform views;
public float transitionSPEED;
Transform currentVIEW;
public void move(){
currentVIEW = views;
transform.position = Vector3.Lerp (transform.position, currentVIEW.position, Time.deltaTime * transitionSPEED);
//for camera rotation
Vector3 currentangel = new Vector3 ( Mathf.LerpAngle(transform.rotation.eulerAngles.x, currentVIEW.transform.rotation.eulerAngles.x, Time.deltaTime *transitionSPEED),
Mathf.LerpAngle(transform.rotation.eulerAngles.y, currentVIEW.transform.rotation.eulerAngles.y, Time.deltaTime *transitionSPEED),
Mathf.LerpAngle(transform.rotation.eulerAngles.z, currentVIEW.transform.rotation.eulerAngles.z, Time.deltaTime *transitionSPEED));
transform.eulerAngles = currentangel;
}
}