Vector3.Lerp and MoveTowards not smoothing (simple script)

public Transform target;
public float smoothing = 5f;
Vector3 offset;
Vector3 targetCamPos;

void Start() {
    offset = transform.position - target.position;
 }

void FixedUpdate() 
{ 
targetCamPos = target.position + offset;                                                           transform.position = Vector3.Lerp(transform.position, targetCamPos, smoothing); 
}

I have copied this code from Unity tutorial. But if I put this code on my camera and attach the transform of my object(that I wanna follow) the camera fly’s away in one direction that is based on the opposite
position of the object. I have also tried to change update/fixedupdate, Time.deltaTime and so on. I never could see the smoothing change (when changing the value). Someone told me that it is a percentage but even then change the value from 0-1 had no impact (the camera would just follow or fly away) but no smoothing. Iam using MacBook Pro and I have the latest version of Unity. I can make a short video so u can see everything? Thanks in advance!

Differences between a position A and some other position B are usually given as (B-A), not the other way around (note that yours is A-B). (B-A) gives the vector required for A to reach B, so this is why your situation is flying away instead of going towards your target.

Since you can think of the t value (your smoothing) of a Lerp as how “close” the result will be to the two Vectors your provide, in your case it’s returning a constant value. That offset value will always be some stagnant vector, but your targetCamPos is also being calculated as the current position plus that.

The code you posted would make more sense if you changed how your target position was being calculated:

targetCamPos = target.position + offset;                                                           
transform.position = Vector3.Lerp(transform.position, targetCamPos, smoothing); 

This would preserve the original offset between your object and its target. You can then change your smoothing value to be something between 0 and 1, as you mentioned, with slow / fast values being close to 0 / 1, respectively.

Thankyou for ur time. I see that I made a mistake copying the last part. So I have now changed (B-A) and target.position + offset but the camera goes then trough the target in a straight line. If I change the Lerp to MoveTowards the camera goes to the target but is not keeping the offset distance and ones he reach the target he goes the same as lerp trough the ground and never turn back. Do you know how I can let the camera follow the target so that it travels always to the offset (with smoothing)?