Unity - A计划(一年有效期) 扫二维码继续学习 二维码时效为半小时

(61评价)
价格: 2165.00元
坦克大战没有声音的问题
Shawn唐发起了问答2018-12-17
1
回复
370
浏览
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shell : MonoBehaviour {
    public GameObject shellExpolsionPrefab;
    public AudioClip shellExplosionAudio;

    public void OnTriggerEnter(Collider other)
    {
        AudioSource.PlayClipAtPoint(shellExplosionAudio, transform.position);
        GameObject.Instantiate(shellExpolsionPrefab, transform.position, transform.rotation); 
        GameObject.Destroy(this.gameObject);


        //print(("Tank"));
        if(other.tag == "Tank") {
            other.SendMessage("TakeDamage");
        }
    }
}

 

好像在坦克大战中,只要是通过

AudioSource.PlayClipAtPoint(shellExplosionAudio, transform.position);

这种方式播放的音乐都没有声音,这个是为什么?

所有回复
  • 老师_Trigger 2018-12-17

    同学你好,同学把声音放到超级大应该是可以听到声音的,这种方式是在某一个点去播放音乐,与游戏物体离相机的距离有关,可以使用AudioSource组件里的Play去播放声音。

    还有-5条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!