- Home /
Question by
xander · Jun 06, 2012 at 03:13 PM ·
accelerationairplane
I need help with my flight controle script
Hey i need help with my flight controle script. The problems are it accelerates side ways. It doesn't rotate and it doesn't go up and if someone knows how to make a aim interface like in battlefield 3 if you are in plane please show me how.
Here is my code
var AmbientSpeed:float = 3
var RollSpeed:float= 2;
var PitchSpeed:float=.5;
var rotFactor:float=0.025;
var angularDrag:float=2;
function Start () {
rigidbody.angularDrag=angularDrag;
}
function FixedUpdate()
{
var AddRot = Quaternion.identity;
var roll:float = 0;
var pitch:float = 0;
var yaw:float = 0; //not used
roll = Input.GetAxis("Mouse X") * RollSpeed;
pitch = Input.GetAxis("Mouse Y") * PitchSpeed;
rigidbody.rotation=rigidbody.rotation*Quaternion.Euler(-pitch,0,-roll);
if (Input.GetAxis"Horizontal")){
rigidbody.AddTorque (Vector3.up * 10);
}
var rotz=transform.eulerAngles.z;
if(rotz>180) {
rotz=rotz-360;
}
rotz=-rotz*rotFactor;
igidbody.AddTorque(Vector3(0,rotz,0));
transform.Translate(Vector3.up * AmbientSpeed * Time.deltaTime);
}
Comment