Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ighazali · Sep 13, 2011 at 09:41 AM · carrace

Ending game after finishing chekpoint

hello, i have been following the race track tutorial, from unity by Morten Sommer, and making a racing game in my neighborhood 3d, addis ababa, Ethiopia.

i have set up the basics and it works perfectly. I added checkpoints and managed to pass through them and display the remaining checkpoints left,play a little pop sound at pick up. using info on this site.

what i couldn't manage to do was having it switch level when the counter reach zero. i tried some of the solutions in here but didn't seem to work. Here is the code i'm using. i hope you guys will help and point me in the right direction. tnx

 var skin:GUISkin;
 var CheckPoint;
 var PickUpSound: AudioClip;
 var BackgroundMusicVolume : float = 0.6;
 
 
 function OnTriggerEnter( other : Collider ) 
 {    
         if (other.tag == "Finish") 
             {        
                 CheckPoint -= 1;     
                 AudioSource.PlayClipAtPoint(PickUpSound,Camera.main.transform.position);
                 volume = BackgroundMusicVolume;
                 Destroy(other.gameObject);
                 
             }
 }
 
 
 function Awake() 
 {
     CheckPoint = 3;
 }
 
 
 function OnGUI()
 {
     GUI.skin = skin;
     GUI.Label( Rect (Screen.width - (Screen.width)/3.5,50, 300, 45),"CheckPoint = " + CheckPoint );
     
 }
 
 function update()
 {
     if ( CheckPoint == 0) 
         {
             Application.LoadLevel("1");
         }
     
 }
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by syclamoth · Sep 13, 2011 at 11:01 AM

Simplest solution- Application.LoadLevel() can be used with either a string or an int. If you call it with a string (like you are doing here), it will look for the level named "1" and try to load that, which of course will not work (unless you actually called your level that). What I prefer to do for this kind of thing, is call Application.LoadLevel(0), which is guaranteed to work (seeing as level 0 will always exist). Try that and see how far you get.

Hope this helps!

Comment
Add comment · Show 1 · Share
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
avatar image ighazali · Sep 13, 2011 at 11:30 AM 0
Share

You two are going on my credit page !

avatar image
1

Answer by japanitrat · Sep 13, 2011 at 10:36 AM

You need to capitalize Update(), because "update()" is not called by Unity (but "Update()" is).

Comment
Add comment · Show 1 · Share
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
avatar image ighazali · Sep 13, 2011 at 11:29 AM 0
Share

thanks, it works

avatar image
0

Answer by ighazali · Oct 01, 2011 at 02:44 PM

As I promised. I added the credits and you can download the game :

http://min.us/lP0Qd6GitbeAG

Comment
Add comment · Share
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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Racing Game - setting up a car TIRES 1 Answer

Best Packages to Make Online Car Race Game 0 Answers

Race checkpoint system small help please :) 1 Answer

How can I create a single car with different settings? 0 Answers

Arcade car phisics 1 Answer


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