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 Roguespectre101 · Oct 31, 2012 at 03:21 AM · fpstimescore

Score through hiting targets and time based score.

Hi guys I know there are a lot of questions about how to make a scoring system but this is going to be a little different because I need something else then what has already been answered.

What I need is a score system that when I have destroyed one of my targets I get points for doing so the way I destroy targets is by using a gun and shooting bullets at targets to destroy them. There are 2 types of targets one set of targets gives you 10 points and the other targets that are optional gives you 50 points I also need to be able to give points based on time so lets say depending on how many seconds are left give the player an extra 10 points per second; I would also like a system that takes points if you miss a target so lets say minus 10 points every time you miss. Basically I'm creating an FPS where the score is based of targets hit and time. Tbh I need this for my uni assignment and I'm just a little stumped and any help would be really useful so yeah please help. btw I have made a start on the code now I just need your help to finish it :).

 // textfield to hold the score and score variable
 private var textfield:GUIText;
 private var score:int;
 
 function Awake(){
 
     textfield = GameObject.Find("GUI/ScoreCount").GetComponent(GUIText);<br />
     score = 0;
     UpdateScoreText();
 }
 function UpdateScoreText(){
 
     // update textfield with score
     textfield.text = score.ToString();
 }

so yeah please help becauase I'm so close to getting this finished and I just need a bit of help to finish this project of :).

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 Fattie · Oct 31, 2012 at 08:41 AM 0
Share

you just need to learn to use Invoke. it is very simple. Go to unityGE$$anonymous$$S.com for a massive explanation

1 Reply

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

Answer by Anusha · Oct 31, 2012 at 04:47 AM

 private var score:int;

 function OnCollisionEnter(other : Collision )
     {
     switch(other.transform.tag)
     {
     case "10points": score+=10; Destroy(other.gameobject);
                              break;
     case "optinal50": score+=50; Destroy(other.gameobject);
                              break;
     default: score-=10;
                           break;
 
 }
 }
 
 //call at the end of game
 function EndGame()
 {
 var bonus = timeRemaining * 10;
 score = score+bonus;
 }

ok.. when your bullet hit any other objects other than your targets the switch will go to default, you will know that you have skipped your target and the score gets deducted. tag your normal target "10points", optional targets "optional50", you have call the EndGame() at gameover so the remaining points gets added to score.... the code is in js now.... i have not tested it though. :)

Comment
Add comment · Show 5 · 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 Roguespectre101 · Oct 31, 2012 at 04:58 AM 0
Share

right this is really good thanks unfortunately I'm only allowed to use JavaScript coding in the project so if you can possibly change it to JavaScript coding that would really help :). also for this code could I tag anything that isn't my code as HitBG because I have a terrain and several game objects that are not the targets so if you hit them you will loose points as well. Anyway your answer has been helpful but I do really need it is as JavaScript so if you can do that I would be really grateful :). p.s that's not to say I'm not grateful already cause I am :).

avatar image Anusha · Oct 31, 2012 at 05:03 AM 0
Share

no dont tag rest of the stuff... i will change the code to suit ur requirement....

avatar image Anusha · Oct 31, 2012 at 05:13 AM 0
Share

accept the answer...

avatar image Roguespectre101 · Oct 31, 2012 at 02:25 PM 0
Share

yay thank you this is really going to help me and thanks for switching it to JavaScript because that's of a lot more use to me. btw how do you list this question as answered.

avatar image Fattie · Oct 31, 2012 at 03:17 PM 0
Share

hi @rogue

look at the TOP and the LEFT of the actual ANSWER. notice there is a number and two "thumb" signs.

notice also a "tick" sign, under the thumbs.

click on that TIC$$anonymous$$ sign.

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

11 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Game Character manager 0 Answers

FPS Multiplayer Help 1 Answer

infinite runner HELP 1 Answer

Collision detection 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