Hello!
I recently changed my camera script, and the new one is really laggy.
Here is the script:
using UnityEngine;
using System.Collections;
public class CarCamera : MonoBehaviour
{
[SerializeField]
private float distanceAway;
[SerializeField]
private float distanceUp;
[SerializeField]
private float smooth;
[SerializeField]
private Transform follow;
private Vector3 targetPosition;
void Start() {
follow = GameObject.FindWithTag ("Player").transform;
}
void OnDrawGizmos () {
}
void LateUpdate ()
{
targetPosition = follow.position + follow.up * distanceUp - follow.forward * distanceAway;
Debug.DrawRay (follow.position, Vector3.up * distanceUp, Color.red);
Debug.DrawRay (follow.position, -1f * follow.forward * distanceAway, Color.blue);
Debug.DrawLine (follow.position, targetPosition, Color.magenta);
transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth);
transform.LookAt (follow);
}
}
And here is the inspector: