Camera following/looking at aircraft

I have the following code so the camera follows the aircraft.

Camera.main.transform.position = Vector3.Lerp(Camera.main.transform.position, transform.position - transform.forward * 10f + transform.up * 2f, 5f * Time.deltaTime);
Camera.main.transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation, transform.rotation, 5f * Time.deltaTime);

I want the camera to be slightly higher the aircraft so you don’t just see the back. That’s why there is an offset in the position. This is working fine, except now the camera is looking ‘over’ the aircraft, in stead of ‘at’. How do I make sure the camera looks at the aircraft, but still follows it’s rotation? Thanks

  1. Create an empty game object that is a CHILD of your aircraft. Name it CameraTarget.

  2. Set it where you want the camera to be (5 units behind, 3 units above the jet or something).

  3. Make the camera’s position follow THAT gameobject, because since it’s locally tied to the jet it’ll always be in the right spot.

  4. Make the camera still rotate towards your aircraft, the rotation code posted should be fine since it’s in worldspace.

  5. Profit!

At least, that SHOULD work. Depending on any child/parent hierarchies you might have on your camera and aircraft, you might have to play around with local space vs. world space.