**Hello, can anyone help to turn the function in void LateUpdate() into a IEnumerator Coroutine so transform.eulerAngles = currentAngle; stops being called once the camera reaches its destination. **
I have a panning function on another script but it won’t work properly because currentAngle keeps firing
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class designerCameraControl : MonoBehaviour
{
public Transform views;
[Space(10)]
public float transitionSpeed;
private Transform currentView;
void FixedUpdate()
{
if (Input.GetMouseButtonDown(0))
{
Ray toMouse = Camera.main.ScreenPointToRay(Input.mousePosition);
bool didHit = Physics.Raycast(toMouse, out RaycastHit rhInfo, 100.0f);
if (rhInfo.collider.name == "Waypoint Handler")
{
{
currentView = views[1];
}
}
if (rhInfo.collider.name == "Waypoint Handler (1)")
{
{
currentView = views[2];
}
}
}
if (Input.GetKey(KeyCode.Escape))
{
{
currentView = views[0];
}
}
}
void LateUpdate()
{
//Lerp position
if (currentView == null) return;
transform.position = Vector3.Lerp(transform.position, currentView.position, Time.deltaTime * transitionSpeed);
Vector3 currentAngle = 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 = currentAngle;
}
}