Unity3D音效问题

//////////////////////2015/08/11/////////////////
/////////////////////by xbw////////////////////////
////////////////////环境 unity4.6.1////////////

今天又拿出之前做的demo,解决了一个小问题,就是人物与食物(加分点)碰撞之后音效不能完整的播放,声音总是不均匀地播放,发现了3D音效的与摄像机的距离的远近将导致声音的大小的增减,这样,在不需要用到3D音效的地方我们把声音改成2D的,这样一来就好了。看一下代码吧
public AudioClip CrashSound;
private AudioSource _audioSource;

void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "shiwu1")
        {
            m_score += 1;
            //_audioSource.PlayOneShot(CrashSound);
            AudioSource.PlayClipAtPoint(CrashSound, GameObject.FindGameObjectWithTag("Player").transform.position);  
            Destroy(GameObject.FindGameObjectWithTag("shiwu1"));   
        }
        if (other.gameObject.tag == "shiwu2")
        {
            m_score += 1;
           // _audioSource.PlayOneShot(CrashSound);
            AudioSource.PlayClipAtPoint(CrashSound, GameObject.FindGameObjectWithTag("Player").transform.position);
            Destroy(GameObject.FindGameObjectWithTag("shiwu2"));        
        }
        if (other.gameObject.tag == "shiwu3")
        {
            m_score += 1;
            //_audioSource.PlayOneShot(CrashSound);
            AudioSource.PlayClipAtPoint(CrashSound, GameObject.FindGameObjectWithTag("Player").transform.position);
            Destroy(GameObject.FindGameObjectWithTag("shiwu3"));      
        }
        if (other.gameObject.tag == "shiwu4")
        {
            m_score += 1;
            //_audioSource.PlayOneShot(CrashSound);
            AudioSource.PlayClipAtPoint(CrashSound, GameObject.FindGameObjectWithTag("Player").transform.position);
            Destroy(GameObject.FindGameObjectWithTag("shiwu4"));
        }

    }

你可能感兴趣的:(Unity3D音效问题)