Unityでゲームをを作っています。
効果音を2種類鳴らせるのですが、2つ以上実装することがどうしてもうまく行きません。
現在このようなプログラムなのですがどのようにすればいいでしょうか
よろしくお願いいたします
C#
1using UnityEngine; 2using System.Collections; 3 4public class BasketContlloer2 : MonoBehaviour 5{ 6 public AudioClip appleSE; 7 public AudioClip gappleSE; 8 public AudioClip bombSE; 9 AudioSource aud; 10 GameObject director; 11 12 void Start() { 13 this.director = GameObject.Find("GameDirector"); 14 this.aud = GetComponent<AudioSource>(); 15 } 16 void OnTriggerEnter(Collider other) { 17 if (other.gameObject.tag == "Apple"){ 18 this.director.GetComponent<GameDirector>().GetApple(); 19 this.aud.PlayOneShot (this.appleSE); 20 } else { 21 this.director.GetComponent<GameDirector>().GetBomb(); 22 this.aud.PlayOneShot (this.bombSE); 23 } 24 Destroy(other.gameObject); 25 } 26 27 // Update is called once per frame 28 void Update() 29 { 30 if (Input.GetMouseButton(0)){ 31 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 32 RaycastHit hit; 33 if (Physics.Raycast(ray, out hit, Mathf.Infinity)) 34 { 35 float x = Mathf.RoundToInt(hit.point.x); 36 float z = Mathf.RoundToInt(hit.point.z); 37 transform.position = new Vector3(x, 0.0f, z); 38 } 39 } 40 } 41} 42
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/08 11:43