- Home /
Question by
jack_sparrow · Oct 03, 2012 at 11:53 AM ·
footballmiss
display goal miss texture in a football game.
following is the code to display goal and miss goal texture. this code works fine but having problem to display "miss Goal" texture.
function OnTriggerEnter(hit : Collider){
if(hit.gameObject.tag == "Ball")
{
//goalDone = true;
//Goal.enabled = true; //make sure you set this to false in the inspector as I said before else it will do nothing
if(countBalls.ballcount==1){
greenPos1.enabled = true;
greyPos1.enabled = false;
//CancelInvoke("DisplayNoGoal");
was_cancelled = true;
}
if(countBalls.ballcount==2){
greenPos2.enabled = true;
greyPos2.enabled = false;
was_cancelled2 = true;
}
play_movie.goal=true;
audio.clip = Goalsound;
audio.Play();
GameObject.Find ("Goal in").GetComponent(BoxCollider).enabled = false;
yield WaitForSeconds(3);
Goal.enabled = false;
play_movie.goal=false;
goalCount++;
finalScore++;
}
}
function OnGUI(){
Debug.Log("Gui texture");
//print("goalCount:"+goalCount);
GUI.Label(new Rect(145,592,200,50),finalScore+"/6",goalStyle);
if(countBalls.ballcount == 1 && !was_cancelled){
//greyPos1.enabled = true;
Invoke("DisplayNoGoal",5.0);
}
if(countBalls.ballcount == 2 && !was_cancelled2){
//greyPos2.enabled = true;
Invoke("DisplayNoGoal2",5.0);
}
}
function DisplayNoGoal()
{
if(countBalls.ballcount == 1 && !was_cancelled){
redPos1.enabled = true;
playmiss();
}
}
function DisplayNoGoal2()
{
if(countBalls.ballcount == 2 && !was_cancelled2){
redPos2.enabled = true;
playmiss();
}
}
function playmiss(){
Play_movie2.miss=true;
//audio.clip = missedsound2;
audio.PlayOneShot(missedsound2);
//audio.Play();
yield WaitForSeconds(3);
//Play_movie2.miss=false;
print(cnt++);
test1 =false;
}
the problem i m facing here is that when once the playmiss() is called then it keeps executing repeativly and it keeps playing the audio in playmiss()...so please let me know where i m making mistake??
Comment