Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Unity 3D Audio Clip Disabled

$
0
0
Hello, I am attempting to make a sound clip play when I destroy an enemy in a space shooter type game. However it keeps giving me the following message: Can not play a disabled audio source UnityEngine.AudioSource:PlayOneShot(AudioClip) EnemyControllerBasic:OnTriggerEnter(Collider) (at Assets/Stewart_Tafari_Lab2/Scripts/EnemyControllerBasic.cs:36). Any idea why it is doing this? using UnityEngine; using System.Collections; public class EnemyControllerBasic : MonoBehaviour { // The game object which spawns us. private ShipPlayerController PlayerShipCtrl; // The game object which spawns the projectile. private Mover Bolt; // The different IDs for the AI states enum AIMode { Normal, Ramming, SteerTowards, Charge }; // The variable which holds the current AI state private AIMode CurrentAIState; // Holds the audio clip to play when // this object is destroyed [SerializeField]AudioClip blowupSfxClip; // List of pickup TYPES to spawn [SerializeField]GameObject[] PickupTypes; // Used to control how fast the game object moves [SerializeField]float MoveSpeed = 4.0f; // The speed to use when in "ramming" mode [SerializeField]float RamSpeed = 5.0f; // The speed to use when in "charge" mode [SerializeField]float ChargeSpeed = 6.0f; // Called by the engine when this object collides // with another object containing collision void OnTriggerEnter (Collider other) { // Hit the player's projectile? if (other.tag == "PlayerProjectile") { // A projectile= instant kills us Destroy(gameObject); // play the blowup audio sfx file audio.PlayOneShot(blowupSfxClip); // Drop a pickup SpawnPickup (); } // Hit the player's ship? else if (other.tag == "PlayerShip") { // Wrecking with the player kills us Destroy(gameObject); // Remove points from the player for hitting the enemy PlayerShipCtrl.ModScore (-1); // Remove shield from the player for hitting the enemy PlayerShipCtrl.ModShield (-1); // Remove health from the player for hitting the enemy PlayerShipCtrl.ModHealth(-1); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>