- Home /
Why isnt OnTriggerEnter Tags working.
So i have the script working but i would like some polish on it as it has a slightly annoying effect. This is what i had working. Its a hover bike that has four thrusters in each corner that also set this off. So it plays my first time audio as well as my other time 4 times.
var firstTime : AudioClip;
var otherTime : AudioClip;
var isfirstTime : boolean = true;
function OnTriggerEnter(){
if(isfirstTime == true){
audio.PlayOneShot(firstTime);
isfirstTime = false;
ScoreManager.finishgame += 1;
}
else{
audio.PlayOneShot(otherTime);
}
}
And this is my attempt to stop it doing that, it plays the first time when i tag a part of the bike with Player but then it doesnt play the other time. ROAR whyyyy
var firstTime : AudioClip;
var otherTime : AudioClip;
var isfirstTime : boolean = true;
function OnTriggerEnter(other:Collider){
if (other.gameObject.tag == "Player"){
if(isfirstTime == true){
audio.PlayOneShot(firstTime);
isfirstTime = false;
ScoreManager.finishgame += 1;
}
}
else{
if (other.gameObject.tag == "Player"){
audio.PlayOneShot(otherTime);
}
}
}
Comment