Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
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
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to reset player position when a ball hits the goal box? 1 Answer

The Script keeps executing..instead executing onec 0 Answers

Free kick unity3d tutorial 1 Answer

Random Fixture Generation 0 Answers

Detect when object in not colliding with collider. 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges