using UnityEngine; public class FPSCarCam : MonoBehaviour { public Rigidbody rig; public float movementAmount = 1f; public float returnAmount = 1f; public float friction = 0.9f; private Vector3 cameraVelocity; private Vector3 lastRigVelocity; private Vector3 startPos; private WobbleShake shake; private void Start() { startPos = base.transform.localPosition; shake = base.transform.root.GetComponentInChildren(); } private void Update() { Vector3 vector = rig.velocity - lastRigVelocity; cameraVelocity -= vector; cameraVelocity -= cameraVelocity * Time.deltaTime * friction; Vector3 vector2 = base.transform.parent.TransformPoint(startPos) - base.transform.position; cameraVelocity += vector2.normalized * Mathf.Pow(vector2.magnitude, 2f) * Time.deltaTime * returnAmount; base.transform.position += cameraVelocity * Time.deltaTime * movementAmount; base.transform.rotation = Quaternion.Lerp(base.transform.rotation, rig.rotation, 10f * Time.deltaTime); lastRigVelocity = rig.velocity; } private void FixedUpdate() { } }