Camera controller not working, value cap or wth is going on?

Hi there people, I am in need of help because I’ve been strugling with the same issue for MONTHS now…

I’ve tried many methods and no one works for me

This is a simple camera follow script I made based on the simplies tutorial I’ve found:

using UnityEngine;

public class VehicleCameraController : MonoBehaviour
{
    public float cameraSpacing = 6f;
    public float followSpeed = 100f;
    public float rotationSpeed = 100f;
    private float angle;
    private float distance;

    private Vector3 cameraPosition;
    private Vector3 smoothPosition;

    public Transform target;

    private void FixedUpdate()
    {
        distance = Mathf.Abs(target.position.magnitude - transform.position.magnitude);
        cameraPosition = target.position - (target.forward * cameraSpacing);
        smoothPosition = Vector3.Lerp(transform.position, cameraPosition, (followSpeed + distance) * Time.fixedDeltaTime);
        transform.position = smoothPosition;

        angle = Mathf.Abs(Quaternion.Angle(transform.rotation, target.rotation));
        transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, (rotationSpeed + angle) * Time.fixedDeltaTime);
    }
}

For some reason values higher than 100f for both ‘followSpeed’ and ‘rotationSpeed’ variables just doesn’t work, this wouldn’t be a problem for a low velocity vehicles, but this vehicle goes 600km/h and faster leaving the camera waaaaaaaaaaaaaaay behind it and I can’t compensate it any way even if I square the distance or multiply by the distance instead of adding it, it doesn’t work, I can’t make the camera to catch up with the vehicle.

I am pretty much done at this point, I just can’t figure out what it is, I’ve tried to run the camera calculations in both Update() and LateUpdate() and it looks like crap, too much jitter in both of those methods.

If you have any sugestion, please, I would appreciate it, may be the issues is somewhere else, not necesary in the camera itself.

Your distance calculation looks incorrect. Distance is calculated either using Vector3.Distance or (target.position - transform.position).magnitude, which is the length of the vector between the positions.

Seems what is happening right now is that if your target is in (100, 0, 0) and your camera is in (0, 0, 100), they are considered to be in the same place becuse their global position has the same magnitude 100.

This isn’t related to the physics system from what I can see therefore I’ll move your post to Scripting.