Flight Control UI
Hey! I have been trying to make a Flight Control code, where i want to control the flight with 2 Control freak joy sticks on adjacent sides, In which i want to control my flight link the gameAERo! ( https://itunes.apple.com/gb/app/aero!/id423650051?mt=8) i already have a flight control code with horizontal & vertical axis, what i want is,,,,,On Input of 2 horizontal axis should results in vertical.
Flight control Code which i have:
var Obj : Rigidbody;
var zrotForce : int = 1;
var MaxRot : int = 90;
var MinRot : int = -90;
var rotupForce : int = 1;
var speed : float;
var speedincrease : float;
var speeddecrease : float;
var Maxspeed : int;
var Minspeed : int;
var takeoffspeed : int;
var lift : int;
var minlift : int;
var hit = false;
function Start () {
InvokeRepeating("Speed", .1, .1);
}
function Speed(){
if (CFInput.GetKey(KeyCode.Space)){ Mathf.Repeat(1,Time.time); speed=speed+speedincrease; } if (CFInput.GetKey(KeyCode.LeftAlt)){ Mathf.Repeat(1,Time.time); speed=speed-speeddecrease; } }
function Update () { var spd = Obj.velocity.magnitude; Obj.rigidbody.AddRelativeForce(0,0,-speed); var H=(CFInput.GetAxis ("Horizontal"))zrotForce; if (H){ Obj.rigidbody.AddRelativeTorque(0, 0, H(spd/100)); } var V=(CFInput.GetAxis ("Vertical"))rotupForce; if (V){ Obj.rigidbody.AddRelativeTorque(V(spd/100), 0, 0); }
if(Maxspeed<=speed){
speed=Maxspeed;
}else{
speed=speed;
}
if(Minspeed>=speed){
speed=Minspeed;
}else{
speed=speed;
}
if (speed<takeoffspeed){
Obj.rigidbody.AddForce(0,minlift,0);
}
if(speed>takeoffspeed){
Obj.rigidbody.AddForce(0,lift,0);
}
if (Obj.rigidbody.rotation.z>MaxRot){
Obj.rigidbody.rotation.z=MaxRot;
}
if (Obj.rigidbody.rotation.z<MinRot){
Obj.rigidbody.rotation.z=MinRot;
}
}
Your answer
Follow this Question
Related Questions
Virtual joysticks for mobile possible? (Mimic controller left & right analogs) 0 Answers
Space Flight Simulator Turning Problems 0 Answers
Jump and movement doesn't works simultaneously 1 Answer
How to get maximum value of a direction working with Joysticks? 1 Answer
How do I create sprites and animate ? 0 Answers