void Initialize() { Is_Working = false; // Get the "AI_CS". aiScript = GetComponentInParent <AI_CS>(); // Set the layer. gameObject.layer = 2; // "Ignore Raycast" layer. // Make this gameobject invisible. var renderer = GetComponent <Renderer>(); if (renderer) { renderer.enabled = false; } // Make this collider a trigger. var collider = GetComponent <Collider>(); if (collider) { collider.isTrigger = true; } // Get the "Drive_Control_CS". driveControlScript = GetComponentInParent <Drive_Control_CS>(); // Get the initial position and scale. thisTransform = transform; currentPos = thisTransform.localPosition; initialPosZ = currentPos.z; currentScale = thisTransform.localScale; }
public override void Prepare(Drive_Control_CS controlScript) { // Store the reference to "Drive_Control_CS". this.controlScript = controlScript; // Store the reference to "AI_CS". aiScript = GetComponentInChildren <AI_CS>(); }
void Initialize() { // Get the "Drive_Control_CS". controlScript = GetComponentInParent <Drive_Control_CS>(); // Set the "maxAngVelocity". maxAngVelocity = Mathf.Deg2Rad * ((controlScript.Max_Speed / (2.0f * Radius * Mathf.PI)) * 360.0f); }
void Get_Max_Velocity() { Transform thisTransform = Selection.activeGameObject.transform; Drive_Control_CS driveControlScript = thisTransform.GetComponentInParent <Drive_Control_CS>(); if (driveControlScript) { Max_VelocityProp.floatValue = driveControlScript.Max_Speed; } }
public void Get_Drive_Script(Drive_Control_CS driveScript, bool isManual, int currentStep) { // Called from "Drive_Control_CS". isWorking = true; this.driveScript = driveScript; // Set the activation of the parents. Manual_Parent.SetActive(isManual); Automatic_Parent.SetActive(!isManual); // Set the current step. if (isManual) { Get_Current_Step(currentStep); } }
void Initial_Settings() { thisAudioSource = GetComponent <AudioSource>(); thisAudioSource.playOnAwake = false; thisAudioSource.loop = true; thisAudioSource.volume = 0.0f; thisAudioSource.Play(); // Find the reference rigidbodies. Transform bodyTransform = transform.parent; if (Left_Reference_Rigidbody == null) { // The left reference wheel has been lost by modifying. if (string.IsNullOrEmpty(Reference_Name_L) == false && string.IsNullOrEmpty(Reference_Parent_Name_L) == false) { Transform leftReferenceTransform = bodyTransform.Find(Reference_Parent_Name_L + "/" + Reference_Name_L); if (leftReferenceTransform) { Left_Reference_Rigidbody = leftReferenceTransform.GetComponent <Rigidbody>(); } } } if (Right_Reference_Rigidbody == null) { // The right reference wheel has been lost by modifying. if (string.IsNullOrEmpty(Reference_Name_R) == false && string.IsNullOrEmpty(Reference_Parent_Name_R) == false) { Transform rightReferenceTransform = bodyTransform.Find(Reference_Parent_Name_R + "/" + Reference_Name_R); if (rightReferenceTransform) { Right_Reference_Rigidbody = rightReferenceTransform.GetComponent <Rigidbody>(); } } } if (Left_Reference_Rigidbody == null || Right_Reference_Rigidbody == null) { Debug.LogWarning("'Reference Rigidbody' for the engine sound cannot be found."); Destroy(this); } // Get the "Drive_Control_CS". driveScript = GetComponentInParent <Drive_Control_CS>(); }
void Initialize() { thisHingeJoint = GetComponent <HingeJoint>(); jointSpring = thisHingeJoint.spring; driveControlScript = GetComponentInParent <Drive_Control_CS>(); // Get the input type. if (inputType != 10) { // This tank is not an AI tank. inputType = General_Settings_CS.Input_Type; } // Set the input script. Set_Input_Script(inputType); // Prepare the input script. if (inputScript != null) { inputScript.Prepare(this); } }
void Debug_Ray_Distance() { GUI.backgroundColor = new Color(1.0f, 1.0f, 0.5f, 1.0f); Drive_Control_CS controlScript = target as Drive_Control_CS; Transform thisTransform = controlScript.transform; Ray ray = new Ray { origin = thisTransform.position, direction = -thisTransform.up }; RaycastHit rayCastHit; if (Physics.Raycast(ray, out rayCastHit, 10.0f, Layer_Settings_CS.Anti_Slipping_Layer_Mask) == true) { // The ray hits the ground. EditorGUILayout.HelpBox("Ray Hit Distance = " + rayCastHit.distance, MessageType.None, false); } else { // The ray does not hit anything. EditorGUILayout.HelpBox("The ground is too far.", MessageType.None, false); } }
public virtual void Prepare(Drive_Control_CS controlScript) { this.controlScript = controlScript; }
void Initialize() { controlScript = GetComponentInParent <Drive_Control_CS>(); }
void Initialize() { thisTransform = transform; // Get "AI_Settings_CS" in the top object. Settings_Script = GetComponentInParent <AI_Settings_CS>(); if (Settings_Script == null) { Debug.LogError("'AI_CS' requires 'AI_Settings_CS' in the top object."); Destroy(this); return; } // Get "Aiming_Control_CS". aimingScript = GetComponentInParent <Aiming_Control_CS>(); // Get "AI_Eye" eyeTransform = thisTransform.Find("AI_Eye"); // (Note.) Do not rename "AI_Eye". if (eyeTransform == null) { Debug.LogError("'AI_Eye' can not be found. "); Destroy(this); } // Get "AI_Hand_CS" script. handScript = thisTransform.GetComponentInChildren <AI_Hand_CS>(); // Get all the "Bullet_Generator_CS" in the tank. bulletGeneratorScripts = thisTransform.parent.GetComponentsInChildren <Bullet_Generator_CS>(); // Instantiate NavMeshAgent object. GameObject agentObject; if (NavMeshAgent_Prefab) { agentObject = Instantiate(NavMeshAgent_Prefab, thisTransform.position, thisTransform.rotation, thisTransform.parent.parent) as GameObject; navAgent = agentObject.GetComponent <NavMeshAgent>(); } else { agentObject = new GameObject("AI_NavMeshAgent_Object"); agentObject.transform.SetPositionAndRotation(thisTransform.position, thisTransform.rotation); agentObject.transform.parent = thisTransform.parent.parent; navAgent = agentObject.AddComponent <NavMeshAgent>(); } navAgentTransform = agentObject.transform; navAgent.acceleration = 120.0f; // 'Follow_Target' settings. if (Settings_Script.Follow_Target) { Get_Follow_Transform(); } else { // // The "Follow_Target" is not set. // Set up the waypoints. Set_WayPoints(); // Set the first waypoint. Update_Next_WayPoint(); } // 'AI_State_Text' settings. if (Settings_Script.AI_State_Text) { UI_AIState_Control_CS stateScript = Settings_Script.AI_State_Text.GetComponent <UI_AIState_Control_CS>(); if (stateScript == null) { stateScript = Settings_Script.AI_State_Text.gameObject.AddComponent <UI_AIState_Control_CS>(); } stateScript.Get_AI_Script(this); } // 'Commander' settings. if (Settings_Script.Commander) { AI_Share_Target_CS shareTargetScript = gameObject.AddComponent <AI_Share_Target_CS>(); shareTargetScript.AI_Script = this; } // Get the "Drive_Control_CS". driveControlScript = GetComponentInParent <Drive_Control_CS>(); // Set the current max speed rate. currentMaxSpeedRate = Max_Speed_Rate * Settings_Script.Patrol_Speed_Rate; }