The idea of a camera that can freely observe irregular high-speed moving objects in unity
In unity, to allow the camera to freely observe a high-speed, irregular motion when a particular key is pressed, it is necessary to calculate the offset between the camera and the observed target at the time the key is pressed for subsequent operations. But there is a problem here, each time you press the button, the offset may have a frame of error, that is, when the button is pressed to observe the distance of the target forward one frame, but the camera is not followed, the calculated offset is too large, resulting in the camera away from the observation target is more and more distant.
The workaround is to add an empty object as the camera's parent node, take the camera as its child, and then let the parent node always follow the observation target (CamParent.transform.position = Target.transform.position), the parent node will go with the camera, so that it can only handle the camera's rotation and pull away from the parent node, without having to deal with camera tracking, in fact the camera is observing its parent node instead of observing the original object, but the final result is the same.
Note that the camera cannot be placed directly under the observation target unless the observed target is stationary or panning, otherwise the rotation of the viewing target causes the lens to rotate. In addition, if the picture needs to be scaled, when the camera is farther away from the viewing target, it can be achieved by adjusting the distance between the camera and the target, which can be achieved by adjusting the camera FOV when the camera is closer to the viewing target, thus avoiding the camera's penetration into the observation target.