- Home /
Using AirBrakes on mobile device with Standard Assets AircraftController
Hey guys, I've been trying to make AirBrakes work on mobile with the AircraftController script from Standard Assets. Changing the bool "AirBrakes" to true with a button doesn't do anything.
I recognized that pressing "Fire1" button works on PC platform, while changing the platform to Android stops it from working. Here is the code that I think is responsible for it. I think the method "AdjustInputForMobileControls" should be changed, but I am not sure how.
private void FixedUpdate()
{
float roll = CrossPlatformInputManager.GetAxis("Horizontal");
float pitch = -CrossPlatformInputManager.GetAxis("Vertical");
bool airBrakes = CrossPlatformInputManager.GetButton("Fire1");
transform.RotateAround(transform.position, Vector3.up, CrossPlatformInputManager.GetAxis("Horizontal") * 9f * Time.deltaTime);
// auto throttle up, or down if braking.
float throttle = airBrakes ? -1 : 1;
#if MOBILE_INPUT
AdjustInputForMobileControls(ref roll, ref pitch, ref throttle);
#endif
m_Aeroplane.Move(roll, pitch, 0, throttle, airBrakes); // Pass the input to the aeroplane
}
private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref float throttle)
{
float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad;
float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad;
roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1);
pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1);
float intendedThrottle = throttle*0.5f + 0.5f;
throttle = Mathf.Clamp(intendedThrottle - m_Aeroplane.Throttle, -1, 1);
}
Your answer
Follow this Question
Related Questions
[C#] Both button check with delay. 1 Answer
Built project, now scripts are missing. 2 Answers
How to open a popup panel asking to restart application after graphics setting adjustment? 0 Answers
How to make the calculated angle respective of the players rotation? 1 Answer
Can I make Money collecting script without attaching it to a object ? I tried but I got error 2 Answers