- Home /
C# colliderに当たると音がなるようにしたい
blockにつけたColliderとPlayerのColliderが当たった時にAudioが再生されるようにしたいのですが、 Assets/saund.cs(16,25): error CS1001: Unexpected symbol `:', expecting identifier エラーがでで再生されません… 解決策をお願いしたいです。
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class saund : MonoBehaviour {
private AudioSource sound01;
void Start () {
//AudioSourceコンポーネントを取得し、変数に格納
sound01 = GetComponent<AudioSource>();
}
void OnTriggerEnter(col : Collider){
if(col.tag == "block"){
sound01.PlayOneShot(sound01.clip);
}
}
}
Comment
Answer by EllisonLee · Oct 10, 2017 at 03:15 AM
https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
C#のスクリプトを使用していると思いますがOnTriggerEnterの書き方はちょっと間違っています..... 上記Documentを参照してください。
Your answer
Follow this Question
Related Questions
[c#]Does audio.Play() work only in Update and Start funcitons? 2 Answers
PlayClipAtPoint Qualify with Type Name 2 Answers
Multiple Cars not working 1 Answer
play sound on click 2 Answers
Distribute terrain in zones 3 Answers