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 eddy11ro · Aug 13, 2012 at 05:27 PM · androidgameselectionracing

Car Selectin Script

Hi ... I'm making a racing game for android and I have some problems with my Car Selection Script .

 **function CarList()
 {
 
 var currentCar : int = PlayerPrefs.GetInt("Quick Race Car");
 
 if (currentCar == 0){
  PlayerPrefs.SetInt("Quick Race Car", 2);
 }
 if (currentCar == 1){
  PlayerPrefs.SetInt("Quick Race Car", 2);
 }
 if (currentCar == 2){
  PlayerPrefs.SetString("Current Q Car", "Audi TT");
 }
 if (currentCar == 3){
  PlayerPrefs.SetString("Current Q Car", "Audi S6");
 }
 if (currentCar == 4){
  PlayerPrefs.SetString("Current Q Car", "BMW M3");
 }
 if (currentCar == 5){
  PlayerPrefs.SetString("Current Q Car", "Ford Mustang");
 }
 if (currentCar == 6){
  PlayerPrefs.SetInt("Quick Race Car", 5);
 }
 }**

This is the car list and the rest of code is this :

 function QuickRace()
 {
  GUILayout.BeginArea (new Rect (25, 12, Screen.width-50, Screen.height-24));
  GUILayout.Label("Select Car : " + PlayerPrefs.GetString("Current Q Car"));
  GUILayout.BeginHorizontal ();
 
  if (GUILayout.Button ("Previous"))
     {
         // go back to the main menu
         PlayerPrefs.SetInt("Quick Race Car", PlayerPrefs.GetInt("Quick Race Car") - 1);
         CarList();
 
     }
 
  if (GUILayout.Button ("Next"))
     {
         // go back to the main menu
         PlayerPrefs.SetInt("Quick Race Car", PlayerPrefs.GetInt("Quick Race Car") + 1);
         CarList();
 
     }
     GUILayout.EndHorizontal();
     
     var currentCar : int = PlayerPrefs.GetInt("Quick Race Car");
     
     // Select The Race Track that you want
     if (currentCar < 2){
  GUILayout.Label (AudiTT);
  }
     if (currentCar == 2){
  GUILayout.Label (AudiTT);
  }
  if (currentCar == 3){
  GUILayout.Label (AudiS6);
  }
  if (currentCar == 4){
  GUILayout.Label (BMWM3);
  }
  if (currentCar == 5){
  GUILayout.Label (FordMustang);
  }
  if (currentCar >= 6){
  GUILayout.Label (FordMustang);
  }
     
  GUILayout.BeginHorizontal ();
     if (GUILayout.Button ("Back"))
     {
         // go back to the main menu
         this.currentGUIMethod = MainMenu;
     }
     GUILayout.EndArea();
 }

but this code is in the main menu script and i want to make it more complex like to add a variable of max speed for example ... and this code don't work any more from when i have update unity to 3.5.5 ... so please help me to make it to optimize it ...

Comment
Add comment · Show 1
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 subcod · Aug 13, 2012 at 05:41 PM 0
Share

Use the switch case statement in java! $$anonymous$$akes it alot easier to read than tons of if statements. here is a tutorial: http://www.youtube.com/watch?v=Ynnh-3yg674

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by subcod · Aug 13, 2012 at 06:22 PM

USE THE SWITCH CASE STATEMENT IN JAVA TO SELECT THE CAR!

here is a tutorial: http://www.youtube.com/watch?v=Ynnh-3yg674

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

8 People are following this question.

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

Related Questions

How do I add bots in android? 2 Answers

Level Button And Quit Button Android 2 Answers

Error UCE0001 ";"Expected 2 Answers

my game is running damn slowly in android device? 1 Answer

Unity Scripting an interactive game tutorial 0 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