audio.Play Help :S

I have been at this for hours and I am really confused about what the problem is.

I have a rigidbody that I want to meow when it hits a certain object. Now this rigidbody also has a point value on it, and my script for adding points works perfectly. So I am not sure why it is not playing the sound. I have tried all sorts of variations of different kind of scripts. Have moved around audio source and script between the rigidbody and the other object. But no sound.

 var meow : AudioClip;
 function OnTriggerEnter(hit : Collider){
   		if(hit.gameObject.tag == "Player"){
   			ScoreSystem.myScore += 1;

Please help :slight_smile:


If you’re still having problems, I use a different method that ALWAYS works: in your code instead of doing playoneshot , I do

AudioSource.PlayClipAtPoint(sound, transform.position);

I can get more specific if you want me to… In fact, here’s an example:

var explosion : Transform;
var blast : AudioClip;

function OnTriggerEnter(hit: Collider)
	if (hit.gameObject.tag=="projectile")
		Instantiate(explosion,transform.position,Quaternion.identity);	//Quaternion.identity takes angle of object
		AudioSource.PlayClipAtPoint(blast, transform.position);


change the script around a bit and make the var like this:

var meow : GameObject;

and then create an empty and assign the sound that you want, after make a prefab and drop the empty that you made in the prefab and erase the empty, after that click on whatever you assigned the script to and drop the prefab on the “meow” game object and see if that will work.