コード例 #1
0
        void Set_Parent_Script(GameObject newObject)
        {
            // Set 'Static_Track_CS' script as parent.
            PTS_Static_Track_CS trackScript = newObject.AddComponent <PTS_Static_Track_CS> ();

            trackScript.Type             = 9;                                                                                                              // Parent ;
            trackScript.Length           = Collider_InfoProp.boundsValue.size.z;
            trackScript.Stored_Body_Mass = thisTransform.parent.GetComponent <Rigidbody> ().mass + (Track_MassProp.floatValue * thisTransform.childCount); // to increase the MainBody's Mass.
            PTS_Drive_Control_CS driveControlScript = thisTransform.parent.GetComponent <PTS_Drive_Control_CS> ();

            if (driveControlScript)
            {
                trackScript.Stored_Torque = driveControlScript.Torque * 1.25f;                 // to increase Torque.
            }
            // Store suspension angles.
            PTS_Create_RoadWheel_CS [] wheelParentScripts  = thisTransform.parent.GetComponentsInChildren <PTS_Create_RoadWheel_CS> ();
            RoadWheelsProp[]           roadWheelsPropArray = new RoadWheelsProp [wheelParentScripts.Length];
            for (int i = 0; i < wheelParentScripts.Length; i++)
            {
                roadWheelsPropArray [i] = wheelParentScripts [i].Get_Current_Angles();
            }
            trackScript.RoadWheelsProp_Array = roadWheelsPropArray;
            // Change children's parent.
            int childCount = thisTransform.childCount;

            for (int i = 0; i < childCount; i++)
            {
                Transform childTransform = thisTransform.GetChild(0);
                childTransform.parent = newObject.transform;
            }
        }
コード例 #2
0
        public RoadWheelsProp Get_Current_Angles()
        { // Called from "PTS_Create_TrackBelt_CSEditor" while converting 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);
        }