Example #1
0
        public AircraftObject(GameObject aircraft) // Aircraft class constructor
        {
            this.aircraft       = aircraft;        // Reference to the aircraft 3D model
            this.throttleSlider =
                GameObject.FindGameObjectWithTag("ThrottleSlider").GetComponent <Slider>();
            // Reference to the UI Throttle Slider
            this.rotationSpeed = throttleSlider.value;
            // Reference to the current value of the UI Throttle Slider

            // Assign the control surfaces
            this.rudder        = ControlSurfaces.rudder;
            this.rightAileron  = ControlSurfaces.rightAileron;
            this.rightElevator = ControlSurfaces.rightElevator;
            this.cloudPivot    = GameObject.Find("CloudPivot");

            // Assign the aircraft rotation start positions
            this.startPosX = aircraft.transform.rotation.x;
            this.startPosY = aircraft.transform.rotation.y;
            this.startPosZ = aircraft.transform.rotation.z;
            this.startPosW = aircraft.transform.rotation.w;
        }
    // Start is called before the first frame update
    void Start()
    {
        // Add references to the control surface objects
        rudder       = ControlSurfaces.rudder;
        leftAileron  = ControlSurfaces.leftAileron;
        leftElevator = ControlSurfaces.leftElevator;

        // Get the relevant start angles for each surface
        rudderZAngle =
            ControlsUtilityMethods.WrapAngle(rudder.GetCurrentRotations().z);
        aileronYAngle =
            ControlsUtilityMethods.WrapAngle(leftAileron.GetCurrentRotations().y);
        elevatorYAngle =
            ControlsUtilityMethods.WrapAngle(leftElevator.GetCurrentRotations().y);

        /* Get the TextMeshPro via code. This text area is where description
         * text is shown to the user */
        var textArray = FindObjectsOfType <TextMeshProUGUI>();

        foreach (var element in textArray)  // loop through all text mesh pro objects
        {
            if (element.tag == "ControlsDescription")
            {   /* If the object is tagged as "ControlsDescription" the reference is stored
                 * in the variable allowing us to print directly into the text box through code */
                controlSurfaceDescriptions = element;
            }
        }

        // Get the UI text box background, enabling us to show and hide it
        controlInputDescriptionBackground =
            GameObject.Find("ControlsDescriptionBackground").GetComponent <Image>();

        // Store initial values of MenuSystem script booleans
        infoIsVisible     = MenuSystem.infoIsVisible;
        controlsIsVisible = MenuSystem.controlsIsVisible;
    }