Example #1
0
        public void AlignToHorizon()
        {
            var altitude   = GetTerrainAltitude();
            var horizontal = transform.forward;

            horizontal.y = altitude < minAltitude ? 0.5f : 0;
            var rotationAngles = Util.AxisAnglesAlt(transform, horizontal, Vector3.up) / 90;

            rotationAngles.x *= 8f;
            rotationAngles.y *= 2f;
            rotationAngles.z *= -1f;
            aircraft.ApplyHeadingControl(rotationAngles);
            aircraft.ApplySpeedControl(1f, 0f);
        }
Example #2
0
        // Update is called once per frame
        public void FixedUpdate()
        {
            // Read input for the pitch, yaw, roll and throttle of the aeroplane.
            var inputRoll     = CrossPlatformInputManager.GetAxis("Roll");
            var inputPitch    = CrossPlatformInputManager.GetAxis("Pitch");
            var inputYaw      = CrossPlatformInputManager.GetAxis("Yaw");
            var inputThrottle = CrossPlatformInputManager.GetAxis("Throttle");
            var inputBrakes   = CrossPlatformInputManager.GetAxis("Brakes");

            // Apply controls
            aircraft.ApplyHeadingControl(inputPitch, inputRoll, inputYaw);
            aircraft.ApplySpeedControl(inputThrottle, inputBrakes);

            // Cycle targets
            if (radar)
            {
                var inputSwitchTarget = CrossPlatformInputManager.GetButtonDown("SwitchTarget");
                if (inputSwitchTarget)
                {
                    radar.CycleTargets();
                }
            }
        }