void Initial_Settings() { thisAudioSource = GetComponent <AudioSource>(); thisAudioSource.playOnAwake = false; thisAudioSource.loop = true; thisAudioSource.volume = 0.0f; thisAudioSource.Play(); // Find the reference script, set the type. turretScript = GetComponent <Turret_Horizontal_CS>(); if (turretScript) { type = 0; // Turret return; } cannonScript = GetComponent <Cannon_Vertical_CS>(); if (cannonScript) { type = 1; // Cannon return; } // The reference script cannot be found. Debug.LogWarning("The reference script for the 'Motor Sound' cannot be found."); Destroy(this); }
public override void Prepare(Cannon_Fire_CS cannoFireScript) { this.cannonFireScript = cannoFireScript; aiScript = transform.root.GetComponentInChildren <AI_CS>(); turretScript = GetComponentInParent <Turret_Horizontal_CS>(); cannonScript = GetComponent <Cannon_Vertical_CS>(); aimingScript = GetComponentInParent <Aiming_Control_CS>(); }