I made a camera script to fit my flight sim game, but the problem is, the camera is always a bit bumpy…meaning it moves in flashes, the camera itself is using LateUpdate and every other script is using Update…
here it goes:
using UnityEngine;
using System.Collections;
public class CameraScript : MonoBehaviour {
public Transform target;
public Vector3 pos;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void LateUpdate () {
if(target)
{
var wantedpos = target.position;
wantedpos += target.right * pos.x;
wantedpos += target.up * pos.y;
wantedpos += target.forward * pos.z;
transform.position = Vector3.Lerp(transform.position, wantedpos, target.rigidbody.velocity.sqrMagnitude + 0.1f);
transform.rotation = Quaternion.Slerp(transform.rotation, target.rotation, 0.1f);
}
}
}
i figured that the problem must be the object moving AFTER the camera, but that cant be right, as the camera is in late update, can anyone help? this is kinda screwing things up…i also tried changing everything else to FixedUpdate, showed a little improvment but didnt work either…