I think I am confused by what you are trying to accomplish. What do Aircraft and Jetfgc refer to, and why are you using something else to control your rotations. What controls the movement and rotation of the plane? (where are your axis controls)
I would suggest writing this script as a full plane controller. This will make it easier for anyone who is working with you on it to help you.
OK, saying this, I tinkered with the script you had, changed it up a bit and made it into a controller, rather than a responder.
I have probably added in alot more features then what you originally had.
First, I used a Plane and mouse ray to figure the direction I wanted to be, then calculated a look rotation based off of that.
Next I adjusted the rotation of the vehicle based on it’s current rotation and the desired rotation.
I changed the velocity based on its heading and speed factor.
Lastly I added in the angular orientation from the difference in X translated to Z and gave it a new Z rotation based off of the current rotation to a desired rotation.
One thing is that the speed dictates the distance of the plane, meaning that the orientation of the target point is farther away when you are traveling faster. (you can’t turn fast at high speeds)
Mouse left speeds you up, mouse right slows you down.
var damping : float = 2.0;
var speed=10.0;
var speedChange=2.0;
var minSpeed=10.0;
var maxSpeed=100.0;
function Start(){
if(!rigidbody)
gameObject.AddComponent(Rigidbody);
rigidbody.interpolation=RigidbodyInterpolation.Extrapolate ;
}
function Update () {
if(Input.GetButton("Fire1"))speed=Mathf.Clamp(speed + speedChange * Time.deltaTime, minSpeed, maxSpeed);
if(Input.GetButton("Fire2"))speed=Mathf.Clamp(speed - speedChange * Time.deltaTime, minSpeed, maxSpeed);
var plane : Plane=Plane(transform.forward, transform.position + transform.forward * speed);
var ray : Ray=Camera.main.ScreenPointToRay(Input.mousePosition);
var dist : float;
plane.Raycast(ray, dist);
var target=ray.GetPoint(dist);
var relativePos = target - transform.position;
var p1=Vector2(transform.forward.x, transform.forward.z);
var p2=Vector2(relativePos.x, relativePos.z);
var angle=Vector2.Angle(p1, p2);
angle=Vector3.Dot(transform.right, relativePos) > 0 ? -angle: angle;
var lookRotation = Quaternion.LookRotation(relativePos);
var rotation=Quaternion.Slerp(transform.rotation, lookRotation, damping * Time.deltaTime);
rigidbody.velocity=transform.forward * speed;
rigidbody.angularVelocity*=0.5;
transform.rotation=rotation;
var z=transform.localEulerAngles.z;
if(z>180)z=z-360;
transform.localEulerAngles.z=Mathf.Lerp(z,angle, damping * 5 * Time.deltaTime);
}
The cool thing is that I stepped away from the actual translation into rigidbody movement and maintained the current orientation to the new one. So when it hits an object it reacts to physics.
I know it looks kind of complicated but if you take the time you will see that at every step I am setting rotations based off of the current rotations. This makes it a bit more believable.
For a camera, I simply attached a smooth follow camera with a zero height.