In Unity's world, the positions of objects are made up of vectors.
What needs to be done today is to keep the camera at a relative distance from the head of the snake.
First, position the snake head at point A, the camera's position at point B.
Then we can know their offset = b-a;
So the new camera position should be B = A + offset;
Make: The motion of the camera is moving according to the frame so it is jitter, we should do a smoothing process
The exact vector gives us a way to use interpolation to move smoothly
Vector3.lerp (B,a + offset,0.1f) That means smooth moving to the middle of the interpolation
Mathf.lerp
static function Lerp (From:float, To:float, t:float): float
Returns the interpolation between A and b based on the floating-point number T, which is limited to 0~1. When t = 0 returns from, when t = 1 returns to. When t = 0.5 returns the mean of the From and to.
Color.lerp
static function Lerp (A:color, B:color, t:float): Color
Interpolates between Colors A and B by T.
"T" is a value sandwiched between 0 and 1. When T is 0 o'clock returns the color A. When T is 1 o'clock returns the color B.
To see the interpolation calculation of Unity in detail
Self-taught Unity3d snake add camera follow