i have all ready try multiple tutorials to get it work but it seems i have some problems to get it work wen the player enter in trigguer space
my code is:
var soundFile:AudioClip;
function OnTriggerEnter(trigger:Collider) {
if(trigger.GetComponent.<Collider>().tag=="cube") {
GetComponent.<AudioSource>().clip = soundFile;
GetComponent.<AudioSource>().Play();
}
}
Well I What to play a sound and ad 10 to my score and destroy the coin
i am new on scripting can some one give hand pls.
There is nothing wrong with your code i tested it only thing i could find wrong was the tag (probably).
Make Sure There is a Audiosource on the trigger itself and remember to make sure the tags are correct for example if you want to play a clip when the player enters a trigger you have to make sure that the script finds the tag “Player” and that the player object is tagged as the “Player” hope this helps!
var soundFile:AudioClip;
function OnTriggerEnter(trigger:Collider) {
if(trigger.GetComponent.<Collider>().tag=="Player") {
GetComponent.<AudioSource>().clip = soundFile;
GetComponent.<AudioSource>().Play();
}
}