void Set_Parent_Script(Static_Track_Parent_CS parentScript)
        {
            // Set the values.
            parentScript.Length           = Collider_InfoProp.boundsValue.size.z;
            parentScript.Stored_Body_Mass = thisTransform.GetComponentInParent <Rigidbody>().mass + (Track_MassProp.floatValue * thisTransform.childCount);             // To increase the MainBody's mass later.

            // Store the roadwheels information.
            Create_RoadWheel_CS[] createRoadWheelScripts = thisTransform.parent.GetComponentsInChildren <Create_RoadWheel_CS>();
            RoadWheelsProp[]      roadWheelsPropArray    = new RoadWheelsProp [createRoadWheelScripts.Length];
            for (int i = 0; i < createRoadWheelScripts.Length; i++)
            {
                // Call "Create_RoadWheel_CS" to get the roadwheels information, such as the wheel radius and the arm angle.
                roadWheelsPropArray [i]            = createRoadWheelScripts [i].Get_Current_Angles();
                roadWheelsPropArray[i].baseRadius += Collider_InfoProp.boundsValue.size.y;                 // Add the hight of the piece.
            }
            parentScript.RoadWheelsProp_Array = roadWheelsPropArray;
        }
Esempio n. 2
0
        public RoadWheelsProp Get_Current_Angles()
        { // Called from "Create_TrackBelt_CSEditor" while converting the 'Physics Track' into 'Static Track'.
            RoadWheelsProp currentProp = new RoadWheelsProp();

            currentProp.parentName = gameObject.name;
            currentProp.baseRadius = Wheel_Radius;
            currentProp.angles     = new float[Num];
            for (int i = 0; i < Num; i++)
            {
                Transform susTransform = transform.Find("Suspension_L_" + (i + 1));
                if (susTransform)
                {
                    float currentAngle = susTransform.localEulerAngles.y;
                    currentAngle          = Mathf.DeltaAngle(0.0f, currentAngle);
                    currentProp.angles[i] = currentAngle;
                }
            }
            return(currentProp);
        }