• 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 shadab_badar · Sep 13, 2013 at 01:26 PM · score

Problem with Scoring System

I am trying to create a game in which I have different balls falling from a defined point and i have to click and destroy the ball and on each clicking a ball provides me some point.I have generated a ball on clicking of which the current score will be doubled.I am trying it but unable to do it.please help me out.

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 $$anonymous$$ · Sep 13, 2013 at 01:28 PM 0
Share

How can we help you, if you didnt post anything?, post your code and you will get some answers.

avatar image ShadoX · Sep 13, 2013 at 11:43 PM 0
Share

As I understand you generate a ball at the position where you click. So you should be half way there. All you need is to change the position where the ball appears and what happens if you click it.

I'm assu$$anonymous$$g that you're new to Unity so a rather simple way to do this would be to have empty game objects in your scene that work as "spawns". The balls could appear at the position of a spawn and then fall assu$$anonymous$$g that those balls are rigidBodies. (check out how to create a prefab.. in this case the easiest would be to create a ball , add a rigidBody to it and save that as a preFab which would then show up at the spawn)

Once you have balls falling you would have to make sure that you can click them. You could try something like at http://answers.unity3d.com/questions/31054/when-mouse-click-a-gameobject-how-can-i-get-the-po.html

Once that's done you could check if you actually clicked on a ball or not and if you did, add a point to some variable that contains that value.

All you would have to do is to get rid of the ball you clicked. The simplest solution would be to use http://docs.unity3d.com/Documentation/ScriptReference/Object.Destroy.html . It would work, but assu$$anonymous$$g that you would do this very often it most probably wouldn't be such a nice solution.

I could suggest what to do, but I guess this should be enough work for you. :)

avatar image shadab_badar · Sep 14, 2013 at 06:56 AM 0
Share

no actually i have balls falling in based on timer if i click a ball it will destroy and will yield me some points and i have few balls which has another features pressing on which may cause game over and may be it will double the present score.i just wanted to ask how can i double the current score on pressing of the ball i want..let the score doubling ball be redball

avatar image vexe · Sep 14, 2013 at 08:03 AM 0
Share

"wanted to ask how can i double the current score on pressing of the ball i want" - Just make a class Ball, give your balls some sort of an identifier like a name or an int id, you can create an enum for the ball type/color.

Then just a simple check:

 if (ballIClickedOn.id == "something") // or name
   // double score

or

 if (ballIClickedOn.Color == $$anonymous$$yColorsEnum.Red)
   // double score

If you have different types of balls, each with vastly different features, you could inherit from Ball, have SuperBall, $$anonymous$$eatBall, BouncingBall, etc. And implement whatever unique features you want in each ball.

Tip for the future: to avoid somebody down-voting you, make your question a bit more detailed, and provide some code showing what you've tried so far :)

Good luck.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Keeping a score from one scene to another? 2 Answers

Play Sound on Score 2 Answers

High score in standalone 1 Answer

PlayerPrefs Highscore problem 1 Answer

can xml be used in anrdoid?? 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