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 Tyler G · Mar 12, 2011 at 08:55 PM · scorecar-tutorial

Car Tutorial scoring

So, i'm attempting to make a score for a the car tutorial.. It's for class and i'm having some issues with it. I'm probably doing something wrong with my coding but i'm attempting to take the basic car and keep the script the same if possible and drive it around on terrain and go off jumps or whatever. What i'm trying to do basically is if the car isn't on the ground I want to add a point to the score Gui every second/frame or whatever that it isn't on the ground and I cannot for the life of me figure out how to do it.. My prefab of the car itself is named Car and my GuiText is scoreGui. Any help would be amazing.. I've tried everything I can think of and it just isn't clicking with me..

var score: int = 0; static var drive = false;

function CalculateState() { { for(gameObject.tag == "Car") { if(gameObject.isGrounded){ var drive = true; } else{ score += 1; guiText.text = "" + score; } }

 }       

}

I've done a slight bit of research and been able to possibly find something more useful to do what i'm trying to do.. but it still isn't working fully

   else{
     var myScore : GUIText = gameObject.Find("ScoreGui").GetComponent(GUIText);
     var score: int = 0;
     score ++;
     myScore.text = "Score: " + score;
    }

I'm attempting to add this to the carScript itself and try to update the score with it attached to the prefab as well.. but i'm not really sure

Comment
Add comment · Show 4
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 Tyler G · Mar 12, 2011 at 09:07 PM 0
Share

I'm personally not even sure if that is the right way of going about it.. I just want to do a basic score update whenever the car is in the air

avatar image Tyler G · Mar 12, 2011 at 09:56 PM 0
Share

do I need to give the car script as well? Is it just that people don't know what i'm actually talking about? I can do that if its needed..

avatar image Tyler G · Mar 12, 2011 at 10:14 PM 0
Share

So I fixed it slightly.. It now shows my Score: 1 but it never changes.. it stays at that static 1 no matter what happens

avatar image Tyler G · Mar 12, 2011 at 10:18 PM 0
Share

apparently I can fix my own mistakes.. i ended up making just a regular var for score ins$$anonymous$$d of down under the else statement and that fixed it.. it updates like I want it to.. It starts at 4, but that isn't a huge deal in my opinion

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

No one has followed this question yet.

Related Questions

Highscore Save 0 Answers

Scoreboard will not update 1 Answer

Don't destroy script on load 2 Answers

Money System Not Working Please Help!!!! (Code fully commented!) 3 Answers

When should I save data 2 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