camera LookAt unwanted flipping - issue

Hi,
Guys I am running to an issue where my camera which is following an airplane flip 180 degree around its local z axis when the plane reaches 90 degree around its x-axis.
For the camera I used standard Unity asset “Smooth LookAt” script:

var target : Transform;
var damping = 6.0;
var smooth = true;

@script AddComponentMenu("Camera-Control/Smooth Look At")

function LateUpdate () {
    if (target) {
        if (smooth)
        {
            // Look at and dampen the rotation
            var rotation = Quaternion.LookRotation(target.position - transform.position);
            transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
        }
        else
        {
            // Just lookat
            transform.LookAt(target);
        }
    }   
}

function Start () {
    // Make the rigid body not change rotation
       if (GetComponent.<Rigidbody>())
        GetComponent.<Rigidbody>().freezeRotation = true;
}

For better illustration of the issue please refer to the following video:

Does anyone know how to fix this issue so that the camera doesn’t flip?

Video is private

oh, sorry. How about now, can you see it?

Easiest solution would be to simply parent the camera to the jet and ignore the LookAt. Buuut, that would make the camera rotate when your jet banks, and I’m guessing you don’t want that. Imagine your player pulls the jet up like that, but continues until he’s upside down, then rolls his jet right side up. What would the desired camera movement/orientation be for each step of that? Define that, and you’ll be halfway to your answer.

UPDATE:
Well, I found this script that solves the flipping issue however when I’m “rolling” to left and right the camera also rotates with the plane, do you know how to eliminate the rolling functionality from the following script?

// The target we are following
var target : Transform;
// The distance in the x-z plane to the target
var distance = 2.0;
// the height we want the camera to be above the target
var height = 5.0;
// How much we
var heightDamping = 2.0;
var rotationDamping = 3.0;
private var oldRotation:Quaternion;
private var targetRotation:Quaternion;
private var currentRotation:Quaternion;
function Start () {
    oldRotation = target.rotation;
}
function Update () {
// Early out if we don't have a target
    if (!target)
        return;
    targetRotation = target.rotation;
    currentRotation = Quaternion.Lerp (oldRotation, targetRotation, rotationDamping * Time.deltaTime);
    oldRotation = currentRotation;
    transform.position = target.position;
    transform.position -= currentRotation * Vector3.forward * distance;
    transform.LookAt(target, target.TransformDirection(Vector3.up));
}

That’s what I was getting at with my comment. The so-called “rolling functionality” is one and the same with the “not flipping when you’re facing upward” functionality. If you want the camera to be parallel to the ground when you’re rolling, it’s also going to flip when the jet’s facing up.

Pretty much the only way around that might be writing some special loop-de-loop detecting functionality that switches it to a mode where it follows the rotation, and then at other times make it follow the horizon.

Go through the process I described in the last comment, and decide what the correct behavior in those scenarios are. Until you do, you’re not going to be able to have a logically consistent camera algorithm.