Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     LocalWing           = GetComponent <Wing>();
     LocalControlSurface = GetComponent <ControlSurface>();
     LocalPropWash       = GetComponent <PropWash>();
     LocalGroundEffect   = GetComponent <GroundEffect>();
 }
    private void OnEnable()
    {
        targetPropwash = target as PropWash;

        // Instantiate undoManager
        UndoManager = new HOEditorUndoManager( targetPropwash, "PropWash" );
    }
Ejemplo n.º 3
0
    private void OnEnable()
    {
        targetPropwash = target as PropWash;

        // Instantiate undoManager
        UndoManager = new HOEditorUndoManager(targetPropwash, "PropWash");
    }
 // Use this for initialization
 void Start()
 {
     LocalWing = GetComponent<Wing>();
     LocalControlSurface = GetComponent<ControlSurface>();
     LocalPropWash = GetComponent<PropWash>();
     LocalGroundEffect = GetComponent<GroundEffect>();
 }
Ejemplo n.º 5
0
 // Use this for initialization
 public void Start()
 {
     WingBoxCollider        = (BoxCollider)gameObject.collider;
     Parent                 = transform.root.gameObject.GetComponent <Rigidbody>();
     ParentAircraft         = transform.root.gameObject.GetComponent <Aircraft>();
     AttachedControlSurface = gameObject.GetComponent <ControlSurface>();
     AttachedPropWash       = gameObject.GetComponent <PropWash>();
     AttachedGroundEffect   = gameObject.GetComponent <GroundEffect>();
 }
 // Use this for initialization
 public void Start()
 {
     WingBoxCollider = (BoxCollider)gameObject.collider;
     Parent = transform.root.gameObject.GetComponent<Rigidbody>();
     ParentAircraft = transform.root.gameObject.GetComponent<Aircraft>();
     AttachedControlSurface = gameObject.GetComponent<ControlSurface>();
     AttachedPropWash = gameObject.GetComponent<PropWash>();
     AttachedGroundEffect = gameObject.GetComponent<GroundEffect>();
 }
    public void OnDrawGizmos()
    {
        //Draw icon.
        Gizmos.DrawIcon (transform.position, "wing.png", true);

        WingBoxCollider = (BoxCollider)gameObject.collider;
        if ( null != WingBoxCollider )
        {
            //Clamp box collider scales.
            WingBoxCollider.size = new Vector3( 1.0f, 0.1f, 1.0f );

            UpdateWingGeometry();

            //Wing geometry.
            Gizmos.color = Color.blue;
            Gizmos.DrawLine( WingRootLeadingEdge, WingTipLeadingEdge );

            Gizmos.color = Color.red;
            Gizmos.DrawLine( WingTipTrailingEdge, WingRootTrailingEdge );

            Gizmos.color = Color.blue;
            Gizmos.DrawLine( WingRootTrailingEdge, WingRootLeadingEdge );
            Gizmos.DrawLine( WingTipLeadingEdge, WingTipTrailingEdge );

            //Sections.
            Gizmos.color = Color.blue;
            for ( int i=0; i<SectionCount; i++ )
            {
                Vector3 sectionStart = WingRootTrailingEdge + ( (WingTipTrailingEdge - WingRootTrailingEdge) * (float)i/(float)SectionCount );
                Vector3 sectionEnd = WingRootLeadingEdge + ( (WingTipLeadingEdge - WingRootLeadingEdge) * (float)i/(float)SectionCount );
                Gizmos.DrawLine( sectionStart, sectionEnd );
            }

            //Lift line.
            Gizmos.color = Color.green;
            Gizmos.DrawLine( RootLiftPosition, TipLiftPosition );

            //Aileron hinge
            AttachedControlSurface = gameObject.GetComponent<ControlSurface>();
            if ( null != AttachedControlSurface )
            {
                float rootHingeOffset = AttachedControlSurface.RootHingeDistanceFromTrailingEdge;
                float tipHingeOffset = AttachedControlSurface.TipHingeDistanceFromTrailingEdge;

                Vector3 wingRootAileronHingePos = WingRootTrailingEdge + ( ( WingRootLeadingEdge - WingRootTrailingEdge ) * rootHingeOffset );
                Vector3 wingTipAileronHingePos = WingTipTrailingEdge + ( ( WingTipLeadingEdge - WingTipTrailingEdge ) * tipHingeOffset );

                Gizmos.color = Color.magenta;
                Gizmos.DrawLine( wingRootAileronHingePos, wingTipAileronHingePos );

                //Control surface - Draw crosses over each control surface section which is affected.
                if ( null != AttachedControlSurface.AffectedSections )
                {
                    for ( int i=0; i<AttachedControlSurface.AffectedSections.Length; i++ )
                    {
                        if ( AttachedControlSurface.AffectedSections[i] == true )
                        {
                            Vector3 hingeLeft = wingRootAileronHingePos + ( (wingTipAileronHingePos - wingRootAileronHingePos ) * ((float)i / (float)AttachedControlSurface.AffectedSections.Length) );
                            Vector3 hingeRight = wingRootAileronHingePos + ( (wingTipAileronHingePos - wingRootAileronHingePos ) * ((float)(i+1) / (float)AttachedControlSurface.AffectedSections.Length) );

                            Vector3 backLeft = WingRootTrailingEdge + ( (WingTipTrailingEdge - WingRootTrailingEdge ) * ((float)i / (float)AttachedControlSurface.AffectedSections.Length) );
                            Vector3 backRight = WingRootTrailingEdge + ( (WingTipTrailingEdge - WingRootTrailingEdge ) * ((float)(i+1) / (float)AttachedControlSurface.AffectedSections.Length) );

                            Gizmos.DrawLine( hingeLeft, backRight );
                            Gizmos.DrawLine( hingeRight, backLeft );
                        }
                    }
                }
            }

            //Prop wash - Draw crosses over each control surface section which is affected.
            AttachedPropWash = gameObject.GetComponent<PropWash>();
            if ( null != AttachedPropWash )
            {
                Gizmos.color = Color.cyan;
                if ( null != AttachedPropWash.AffectedSections )
                {
                    for ( int i=0; i<AttachedPropWash.AffectedSections.Length; i++ )
                    {
                        if ( AttachedPropWash.AffectedSections[i] == true )
                        {
                            Vector3 frontLeft = WingRootLeadingEdge + ( (WingTipLeadingEdge - WingRootLeadingEdge ) * ((float)i / (float)AttachedPropWash.AffectedSections.Length) );
                            Vector3 frontRight = WingRootLeadingEdge + ( (WingTipLeadingEdge - WingRootLeadingEdge ) * ((float)(i+1) / (float)AttachedPropWash.AffectedSections.Length) );

                            Vector3 backLeft = WingRootTrailingEdge + ( (WingTipTrailingEdge - WingRootTrailingEdge ) * ((float)i / (float)AttachedPropWash.AffectedSections.Length) );
                            Vector3 backRight = WingRootTrailingEdge + ( (WingTipTrailingEdge - WingRootTrailingEdge ) * ((float)(i+1) / (float)AttachedPropWash.AffectedSections.Length) );

                            //Vector3 topCenter = hingeLeft + ( (hingeRight-hingeLeft) * 0.5f );
                            //Vector3 bottomCenter = backLeft + ( (backRight-backLeft) * 0.5f );
                            ///Vector3 leftCenter = backLeft + ( (hingeLeft-backLeft) * 0.5f );
                            //Vector3 rightCenter = backRight + ( (hingeRight-backRight) * 0.5f );

                            Gizmos.DrawLine( frontLeft, backRight );
                            Gizmos.DrawLine( frontRight, backLeft );
                        }
                    }
                }
            }

        }
    }
Ejemplo n.º 8
0
    public void OnDrawGizmos()
    {
        //Draw icon.
        Gizmos.DrawIcon(transform.position, "wing.png", true);

        WingBoxCollider = (BoxCollider)gameObject.collider;
        if (null != WingBoxCollider)
        {
            //Clamp box collider scales.
            WingBoxCollider.size = new Vector3(1.0f, 0.1f, 1.0f);

            UpdateWingGeometry();

            //Wing geometry.
            Gizmos.color = Color.blue;
            Gizmos.DrawLine(WingRootLeadingEdge, WingTipLeadingEdge);

            Gizmos.color = Color.red;
            Gizmos.DrawLine(WingTipTrailingEdge, WingRootTrailingEdge);

            Gizmos.color = Color.blue;
            Gizmos.DrawLine(WingRootTrailingEdge, WingRootLeadingEdge);
            Gizmos.DrawLine(WingTipLeadingEdge, WingTipTrailingEdge);


            //Sections.
            Gizmos.color = Color.blue;
            for (int i = 0; i < SectionCount; i++)
            {
                Vector3 sectionStart = WingRootTrailingEdge + ((WingTipTrailingEdge - WingRootTrailingEdge) * (float)i / (float)SectionCount);
                Vector3 sectionEnd   = WingRootLeadingEdge + ((WingTipLeadingEdge - WingRootLeadingEdge) * (float)i / (float)SectionCount);
                Gizmos.DrawLine(sectionStart, sectionEnd);
            }

            //Lift line.
            Gizmos.color = Color.green;
            Gizmos.DrawLine(RootLiftPosition, TipLiftPosition);

            //Aileron hinge
            AttachedControlSurface = gameObject.GetComponent <ControlSurface>();
            if (null != AttachedControlSurface)
            {
                float rootHingeOffset = AttachedControlSurface.RootHingeDistanceFromTrailingEdge;
                float tipHingeOffset  = AttachedControlSurface.TipHingeDistanceFromTrailingEdge;

                Vector3 wingRootAileronHingePos = WingRootTrailingEdge + ((WingRootLeadingEdge - WingRootTrailingEdge) * rootHingeOffset);
                Vector3 wingTipAileronHingePos  = WingTipTrailingEdge + ((WingTipLeadingEdge - WingTipTrailingEdge) * tipHingeOffset);

                Gizmos.color = Color.magenta;
                Gizmos.DrawLine(wingRootAileronHingePos, wingTipAileronHingePos);

                //Control surface - Draw crosses over each control surface section which is affected.
                if (null != AttachedControlSurface.AffectedSections)
                {
                    for (int i = 0; i < AttachedControlSurface.AffectedSections.Length; i++)
                    {
                        if (AttachedControlSurface.AffectedSections[i] == true)
                        {
                            Vector3 hingeLeft  = wingRootAileronHingePos + ((wingTipAileronHingePos - wingRootAileronHingePos) * ((float)i / (float)AttachedControlSurface.AffectedSections.Length));
                            Vector3 hingeRight = wingRootAileronHingePos + ((wingTipAileronHingePos - wingRootAileronHingePos) * ((float)(i + 1) / (float)AttachedControlSurface.AffectedSections.Length));

                            Vector3 backLeft  = WingRootTrailingEdge + ((WingTipTrailingEdge - WingRootTrailingEdge) * ((float)i / (float)AttachedControlSurface.AffectedSections.Length));
                            Vector3 backRight = WingRootTrailingEdge + ((WingTipTrailingEdge - WingRootTrailingEdge) * ((float)(i + 1) / (float)AttachedControlSurface.AffectedSections.Length));

                            Gizmos.DrawLine(hingeLeft, backRight);
                            Gizmos.DrawLine(hingeRight, backLeft);
                        }
                    }
                }
            }

            //Prop wash - Draw crosses over each control surface section which is affected.
            AttachedPropWash = gameObject.GetComponent <PropWash>();
            if (null != AttachedPropWash)
            {
                Gizmos.color = Color.cyan;
                if (null != AttachedPropWash.AffectedSections)
                {
                    for (int i = 0; i < AttachedPropWash.AffectedSections.Length; i++)
                    {
                        if (AttachedPropWash.AffectedSections[i] == true)
                        {
                            Vector3 frontLeft  = WingRootLeadingEdge + ((WingTipLeadingEdge - WingRootLeadingEdge) * ((float)i / (float)AttachedPropWash.AffectedSections.Length));
                            Vector3 frontRight = WingRootLeadingEdge + ((WingTipLeadingEdge - WingRootLeadingEdge) * ((float)(i + 1) / (float)AttachedPropWash.AffectedSections.Length));

                            Vector3 backLeft  = WingRootTrailingEdge + ((WingTipTrailingEdge - WingRootTrailingEdge) * ((float)i / (float)AttachedPropWash.AffectedSections.Length));
                            Vector3 backRight = WingRootTrailingEdge + ((WingTipTrailingEdge - WingRootTrailingEdge) * ((float)(i + 1) / (float)AttachedPropWash.AffectedSections.Length));

                            //Vector3 topCenter = hingeLeft + ( (hingeRight-hingeLeft) * 0.5f );
                            //Vector3 bottomCenter = backLeft + ( (backRight-backLeft) * 0.5f );
                            ///Vector3 leftCenter = backLeft + ( (hingeLeft-backLeft) * 0.5f );
                            //Vector3 rightCenter = backRight + ( (hingeRight-backRight) * 0.5f );

                            Gizmos.DrawLine(frontLeft, backRight);
                            Gizmos.DrawLine(frontRight, backLeft);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        //Make sure we have a parent wing before we try and do anything and also make sure they are similarly parented.
        if ( (null != ParentWing) && (transform.root.gameObject == ParentWing.transform.root.gameObject) )
        {
            //Do not try and copy self.
            if ( this == ParentWing )
            {
                return;
            }

            //Copy name..
            gameObject.name = ParentWing.name + "(Mirror)";

            //First copy transforms..
            transform.localScale = new Vector3( -ParentWing.transform.localScale.x, ParentWing.transform.localScale.y, ParentWing.transform.localScale.z );
            transform.localPosition = ParentWing.transform.localPosition;
            transform.localPosition = new Vector3( -transform.localPosition.x, transform.localPosition.y, transform.localPosition.z );

            transform.localRotation = new Quaternion( -ParentWing.transform.localRotation.x,
                                                        ParentWing.transform.localRotation.y,
                                                        ParentWing.transform.localRotation.z,
                                                        ParentWing.transform.localRotation.w * -1.0f);

            //Copy wing
            if ( !LocalWing && ParentWing )
            {
                LocalWing = gameObject.AddComponent<Wing>();
            }

            if ( LocalWing )
            {
                //EditorUtility.CopySerialized( ParentWing, LocalWing ); //**CRASHES ON 3.5

                LocalWing.SectionCount = ParentWing.SectionCount;
                LocalWing.WingTipWidthZeroToOne = ParentWing.WingTipWidthZeroToOne;
                LocalWing.WingTipSweep = ParentWing.WingTipSweep;
                LocalWing.WingTipAngle = ParentWing.WingTipAngle;
                LocalWing.Aerofoil = ParentWing.Aerofoil;
                LocalWing.CDOverride = ParentWing.CDOverride;
            }

            //Copy control surface
            ControlSurface parentControlSurface = ParentWing.GetComponent<ControlSurface>();
            if (!LocalControlSurface && parentControlSurface )
            {
                LocalControlSurface = gameObject.AddComponent<ControlSurface>();
            }
            if ( LocalControlSurface )
            {
                //string previousLocalAxisName = LocalControlSurface.AxisName;
                bool previousLocalInvert = LocalControlSurface.Invert;
                GameObject previousModel = LocalControlSurface.Model;
                Vector3 previousRotationAxis = LocalControlSurface.ModelRotationAxis;

                //EditorUtility.CopySerialized( parentControlSurface, LocalControlSurface ); //**CRASHES ON 3.5

                LocalControlSurface.AxisName = parentControlSurface.AxisName;
                LocalControlSurface.Invert = parentControlSurface.Invert;
                LocalControlSurface.MaxDeflectionDegrees = parentControlSurface.MaxDeflectionDegrees;
                LocalControlSurface.RootHingeDistanceFromTrailingEdge = parentControlSurface.RootHingeDistanceFromTrailingEdge;
                LocalControlSurface.TipHingeDistanceFromTrailingEdge = parentControlSurface.TipHingeDistanceFromTrailingEdge;
                LocalControlSurface.AffectedSections = parentControlSurface.AffectedSections;
                LocalControlSurface.Model = parentControlSurface.Model;
                LocalControlSurface.ModelRotationAxis = parentControlSurface.ModelRotationAxis;

                //Keep the following unique.
                //LocalControlSurface.AxisName = previousLocalAxisName;
                LocalControlSurface.Invert = previousLocalInvert;
                LocalControlSurface.Model = previousModel;
                LocalControlSurface.ModelRotationAxis = previousRotationAxis;
            }

            //Copy propwash
            PropWash parentPropWash = ParentWing.GetComponent<PropWash>();
            if (!LocalPropWash && parentPropWash )
            {
                LocalPropWash = gameObject.AddComponent<PropWash>();
            }
            if ( LocalPropWash )
            {
                Engine previousPropwashSource = LocalPropWash.PropWashSource;

                //Copy everything except propwash source..
                LocalPropWash.AffectedSections = parentPropWash.AffectedSections;
                LocalPropWash.PropWashSource = parentPropWash.PropWashSource;
                LocalPropWash.PropWashStrength = parentPropWash.PropWashStrength;

                //Keep unique
                LocalPropWash.PropWashSource = previousPropwashSource;
            }
        }
    }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        //Make sure we have a parent wing before we try and do anything and also make sure they are similarly parented.
        if ((null != ParentWing) && (transform.root.gameObject == ParentWing.transform.root.gameObject))
        {
            //Do not try and copy self.
            if (this == ParentWing)
            {
                return;
            }

            //Copy name ( only if changed )
            string newName = ParentWing.name + "(Mirror)";
            if (gameObject.name != newName)
            {
                gameObject.name = newName;
            }

            //First copy transforms..
            transform.localScale    = new Vector3(-ParentWing.transform.localScale.x, ParentWing.transform.localScale.y, ParentWing.transform.localScale.z);
            transform.localPosition = ParentWing.transform.localPosition;
            transform.localPosition = new Vector3(-transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);

            transform.localRotation = new Quaternion(-ParentWing.transform.localRotation.x,
                                                     ParentWing.transform.localRotation.y,
                                                     ParentWing.transform.localRotation.z,
                                                     ParentWing.transform.localRotation.w * -1.0f);

            //Copy wing
            if (!LocalWing && ParentWing)
            {
                LocalWing = gameObject.AddComponent <Wing>();
            }
            if (LocalWing && ParentWing)
            {
                LocalWing.SectionCount          = ParentWing.SectionCount;
                LocalWing.WingTipWidthZeroToOne = ParentWing.WingTipWidthZeroToOne;
                LocalWing.WingTipSweep          = ParentWing.WingTipSweep;
                LocalWing.WingTipAngle          = ParentWing.WingTipAngle;
                LocalWing.Aerofoil   = ParentWing.Aerofoil;
                LocalWing.CDOverride = ParentWing.CDOverride;
            }
            else if (LocalWing && !ParentWing)
            {
                //deleted on parent since copying.
                DestroyImmediate(LocalWing);
            }

            //Copy control surface
            ControlSurface parentControlSurface = ParentWing.GetComponent <ControlSurface>();
            if (!LocalControlSurface && parentControlSurface)
            {
                LocalControlSurface = gameObject.AddComponent <ControlSurface>();
            }
            if (LocalControlSurface && parentControlSurface)
            {
                //string previousLocalAxisName = LocalControlSurface.AxisName;
                GameObject previousModel        = LocalControlSurface.Model;
                Vector3    previousRotationAxis = LocalControlSurface.ModelRotationAxis;

                LocalControlSurface.MaxDeflectionDegrees = parentControlSurface.MaxDeflectionDegrees;
                LocalControlSurface.RootHingeDistanceFromTrailingEdge = parentControlSurface.RootHingeDistanceFromTrailingEdge;
                LocalControlSurface.TipHingeDistanceFromTrailingEdge  = parentControlSurface.TipHingeDistanceFromTrailingEdge;
                LocalControlSurface.AffectedSections  = parentControlSurface.AffectedSections;
                LocalControlSurface.Model             = parentControlSurface.Model;
                LocalControlSurface.ModelRotationAxis = parentControlSurface.ModelRotationAxis;

                //Keep the following unique.
                LocalControlSurface.Model             = previousModel;
                LocalControlSurface.ModelRotationAxis = previousRotationAxis;
            }
            else if (LocalControlSurface && !parentControlSurface)
            {
                //deleted on parent since copying.
                DestroyImmediate(LocalControlSurface);
            }

            //Copy propwash
            PropWash parentPropWash = ParentWing.GetComponent <PropWash>();
            if (!LocalPropWash && parentPropWash)
            {
                LocalPropWash = gameObject.AddComponent <PropWash>();
            }
            if (LocalPropWash && parentPropWash)
            {
                Engine previousPropwashSource = LocalPropWash.PropWashSource;

                //Copy everything except propwash source..
                LocalPropWash.AffectedSections = parentPropWash.AffectedSections;
                LocalPropWash.PropWashSource   = parentPropWash.PropWashSource;
                LocalPropWash.PropWashStrength = parentPropWash.PropWashStrength;

                //Keep unique
                LocalPropWash.PropWashSource = previousPropwashSource;
            }
            else if (LocalPropWash && !parentPropWash)
            {
                //deleted on parent since copying.
                DestroyImmediate(LocalPropWash);
            }

            //Copy groundeffect.
            GroundEffect parentGroundEffect = ParentWing.GetComponent <GroundEffect>();
            if (!LocalGroundEffect && parentGroundEffect)
            {
                LocalGroundEffect = gameObject.AddComponent <GroundEffect>();
            }
            if (LocalGroundEffect && parentGroundEffect)
            {
                //Copy everything..
                LocalGroundEffect.CLHeightVsChord = parentGroundEffect.CLHeightVsChord;
                LocalGroundEffect.CDHeightVsSpan  = parentGroundEffect.CDHeightVsSpan;
                LocalGroundEffect.RayCastAxis     = parentGroundEffect.RayCastAxis;
                LocalGroundEffect.RayCastLayers   = parentGroundEffect.RayCastLayers;
                LocalGroundEffect.Wingspan        = parentGroundEffect.Wingspan;
            }
            else if (LocalGroundEffect && !parentGroundEffect)
            {
                //deleted on parent since copying.
                DestroyImmediate(LocalGroundEffect);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Make sure we have a parent wing before we try and do anything and also make sure they are similarly parented.
        if ( (null != ParentWing) && (transform.root.gameObject == ParentWing.transform.root.gameObject) )
        {
            //Do not try and copy self.
            if ( this == ParentWing )
            {
                return;
            }

            //Copy name ( only if changed )
            string newName = ParentWing.name + "(Mirror)";
            if ( gameObject.name != newName )
            {
                gameObject.name = newName;
            }

            //First copy transforms..
            transform.localScale = new Vector3( -ParentWing.transform.localScale.x, ParentWing.transform.localScale.y, ParentWing.transform.localScale.z );
            transform.localPosition = ParentWing.transform.localPosition;
            transform.localPosition = new Vector3( -transform.localPosition.x, transform.localPosition.y, transform.localPosition.z );

            transform.localRotation = new Quaternion( -ParentWing.transform.localRotation.x,
                                                        ParentWing.transform.localRotation.y,
                                                        ParentWing.transform.localRotation.z,
                                                        ParentWing.transform.localRotation.w * -1.0f);

            //Copy wing
            if ( !LocalWing && ParentWing )
            {
                LocalWing = gameObject.AddComponent<Wing>();
            }
            if ( LocalWing && ParentWing )
            {
                LocalWing.SectionCount = ParentWing.SectionCount;
                LocalWing.WingTipWidthZeroToOne = ParentWing.WingTipWidthZeroToOne;
                LocalWing.WingTipSweep = ParentWing.WingTipSweep;
                LocalWing.WingTipAngle = ParentWing.WingTipAngle;
                LocalWing.Aerofoil = ParentWing.Aerofoil;
                LocalWing.CDOverride = ParentWing.CDOverride;
            }
            else if ( LocalWing && !ParentWing )
            {
                //deleted on parent since copying.
                DestroyImmediate( LocalWing );
            }

            //Copy control surface
            ControlSurface parentControlSurface = ParentWing.GetComponent<ControlSurface>();
            if (!LocalControlSurface && parentControlSurface )
            {
                LocalControlSurface = gameObject.AddComponent<ControlSurface>();
            }
            if ( LocalControlSurface && parentControlSurface )
            {
                //string previousLocalAxisName = LocalControlSurface.AxisName;
                GameObject previousModel = LocalControlSurface.Model;
                Vector3 previousRotationAxis = LocalControlSurface.ModelRotationAxis;

                LocalControlSurface.MaxDeflectionDegrees = parentControlSurface.MaxDeflectionDegrees;
                LocalControlSurface.RootHingeDistanceFromTrailingEdge = parentControlSurface.RootHingeDistanceFromTrailingEdge;
                LocalControlSurface.TipHingeDistanceFromTrailingEdge = parentControlSurface.TipHingeDistanceFromTrailingEdge;
                LocalControlSurface.AffectedSections = parentControlSurface.AffectedSections;
                LocalControlSurface.Model = parentControlSurface.Model;
                LocalControlSurface.ModelRotationAxis = parentControlSurface.ModelRotationAxis;

                //Keep the following unique.
                LocalControlSurface.Model = previousModel;
                LocalControlSurface.ModelRotationAxis = previousRotationAxis;
            }
            else if ( LocalControlSurface && !parentControlSurface )
            {
                //deleted on parent since copying.
                DestroyImmediate( LocalControlSurface );
            }

            //Copy propwash
            PropWash parentPropWash = ParentWing.GetComponent<PropWash>();
            if (!LocalPropWash && parentPropWash )
            {
                LocalPropWash = gameObject.AddComponent<PropWash>();
            }
            if ( LocalPropWash && parentPropWash )
            {
                Engine previousPropwashSource = LocalPropWash.PropWashSource;

                //Copy everything except propwash source..
                LocalPropWash.AffectedSections = parentPropWash.AffectedSections;
                LocalPropWash.PropWashSource = parentPropWash.PropWashSource;
                LocalPropWash.PropWashStrength = parentPropWash.PropWashStrength;

                //Keep unique
                LocalPropWash.PropWashSource = previousPropwashSource;
            }
            else if ( LocalPropWash && !parentPropWash )
            {
                //deleted on parent since copying.
                DestroyImmediate( LocalPropWash );
            }

            //Copy groundeffect.
            GroundEffect parentGroundEffect = ParentWing.GetComponent<GroundEffect>();
            if (!LocalGroundEffect && parentGroundEffect )
            {
                LocalGroundEffect = gameObject.AddComponent<GroundEffect>();
            }
            if ( LocalGroundEffect && parentGroundEffect )
            {
                //Copy everything..
                LocalGroundEffect.CLHeightVsChord = parentGroundEffect.CLHeightVsChord;
                LocalGroundEffect.CDHeightVsSpan = parentGroundEffect.CDHeightVsSpan;
                LocalGroundEffect.RayCastAxis = parentGroundEffect.RayCastAxis;
                LocalGroundEffect.RayCastLayers = parentGroundEffect.RayCastLayers;
                LocalGroundEffect.Wingspan = parentGroundEffect.Wingspan;
            }
            else if ( LocalGroundEffect && !parentGroundEffect )
            {
                //deleted on parent since copying.
                DestroyImmediate( LocalGroundEffect );
            }
        }
    }