float speedFactor = Mathf.Clamp01(target.root.rigidbody.velocity.magnitude / 70.0f); //Debug.Log(speedFactor);//根据物体的速度变化产生的系数,速度越大,系数越大 camera.fieldOfView = Mathf.Lerp(55, 72, speedFactor); float currentDistance = Mathf.Lerp(7.5f, 6.5f, speedFactor); currentVelocity = currentVelocity.normalized; Vector3 newTargetPosition = target.position + Vector3.up * height;/上面 Vector3 newPosition = newTargetPosition - (currentVelocity * currentDistance);/后面一点距离 //Debug.Log(newPosition); newPosition.y = newTargetPosition.y;//高度保持不变 Vector3 targetDirection = newPosition - newTargetPosition; if(Physics.Raycast(newTargetPosition, targetDirection, out hit, currentDistance, raycastLayers)) newPosition = hit.point; transform.position = newPosition;//摄像机位置变化 transform.LookAt(newTargetPosition);//摄像机朝向汽车方向