using UnityEngine; using System.Collections; public class PlaySound : MonoBehaviour { private AudioSource sound01; void Start() { sound01 = GetComponent<AudioSource>(); } //オブジェクトが衝突したときSE再生 void OnCollisionEnter(Collision collision) { sound01.PlayOneShot(sound01.clip); } }
上記の”//オブジェクトが衝突したときSE再生”の処理をゲーム実行から10秒後に実行させ始めたいのですが
どう記述すれば良いのでしょうか。
using UnityEngine; using System.Collections; public class PlaySound : MonoBehaviour { private AudioSource sound01; void Start() { sound01 = GetComponent<AudioSource>(); Invoke("OnCollisionEnter", 10.0f); //追記 } //オブジェクトが衝突したときSE再生 void OnCollisionEnter(Collision collision) { sound01.PlayOneShot(sound01.clip); } }
↑Invokeを使い書き換えてみたのですがうまくいきません
回答2件
あなたの回答
tips
プレビュー