Upgrade to Pro — share decks privately, control downloads, hide ads and more …

1WeekGameJam準備会 ゲームにサウンドをつけてみよう

1WeekGameJam準備会 ゲームにサウンドをつけてみよう

2018/06/03(日) 秋葉原Weeybleで行われた、 Unityもくもく勉強会×1週間ゲームジャム準備会のLT#2です。

zarakima

June 03, 2018
Tweet

Other Decks in Programming

Transcript

  1. ͋ΔλΠϛϯάͰԻΛग़͢ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class

    SingleSound : MonoBehaviour {
 
 // Կ͔ʹ౰ͨͬͨΒ
 void OnTriggerEnter(Collider other) {
 
 // ԻΛग़͢
 GetComponent<AudioSource>().Play();
 }
 
 }
 AudioSourceʢͱAudioClip)͕௥Ճ͞Ε͍ͯΔήʔϜ ΦϒδΣΫτʹɺҎԼͷεΫϦϓτΛ௥Ճ͢Δ
  2. ෳ਺ͷԻΛग़͢ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class

    TripleSound : MonoBehaviour {
 
 
 public AudioClip enemySE;
 public AudioClip stoneSE;
 public AudioClip wallSE;
 private AudioSource audioSource;
 
 void Start() {
 audioSource = GetComponent<AudioSource>();
 }
 
 void OnTriggerEnter(Collider other) {
 
 if (other.gameObject.tag == "enemy") {
 audioSource.PlayOneShot(enemySE);
 } else if (other.gameObject.tag == "stone") {
 audioSource.PlayOneShot(stoneSE);
 } else {
 audioSource.PlayOneShot(wallSE);
 }
 
 }
 
 }