• 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
Question by Meebo · Aug 30, 2012 at 01:37 PM · objectshowcountdownmakedestroyed

How to make a coundown of destroyed objects ?

I want the game to show the number "5" on the top of the screen . I made some Spheres so if you click them the are destroyed . I want the number to change to 4 when I click on 1 ball , 3 when I click on 2 balls ... At 0 I want it to Load another scene .

How can I do it ? help please ! THX !

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Mander · Aug 30, 2012 at 02:09 PM

1.-u need an empty game object with an script attached to count to 0 and to display ur text. 2.-u need a GUIText on ur screen. 3.-u need a the script to destroy ur balls.

so based on what u already have.

make an empty gameobject leve it anywhere. t$$anonymous$$s will only hold the previous mentioned script so it wont get destroyed and stop working.

1st script: name it whatever u want ill name it "GUIsphere"

 //1st declare a variable to hold ur GUIText and controll its properties and ur cont variable
 
 var referenceToText : GUIText;
 var number : int;
 //remember to assign the guitext on the inspector tab
 //then in the update call the referenceToText and the number and printit every Update
 void Update(){
     referenceToText.Text = ("Spheres left:"+number);
 }
 
 then on ur script where u destroy each ball. just add the following line 
 
 GameObject.Find("emptyGameobject").GetComponent("GUIsphere").number -=1;
 
 //emptyGameobject is the name of the empty gameobject that holds the GUI script
Comment
mosab079

People who like this

1 Show 6 · 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 Meebo · Aug 30, 2012 at 03:08 PM 0
Share

Hey Fattie , I know how to use GUI , I needed help in the whole script . thx anyway :)

Mander , Thank you , you helped me a lot , but I didn't do exactly what you did :)

Now i need help in : how to load another level on 0 .

avatar image Mander · Aug 30, 2012 at 03:09 PM 0
Share

no worries man, even better if u did it ur way! .

avatar image Meebo · Aug 30, 2012 at 03:45 PM 0
Share

I need you to help me again , you probably didn't noticed the last sentence because I edited the comment .

avatar image Mander · Aug 30, 2012 at 03:50 PM 0
Share

normaly u should be doing another question. those are the rules of the UAnswers but ill help u since is an ez line.

just on ur update on the GUIsphere script make an if (number == 0){ Application.LoadLevel("level2"); }

avatar image Meebo · Aug 30, 2012 at 04:10 PM 0
Share

I did it too but I forgot to right two equals so it gave me an error . Now I have another problem , It doesn't load the level but not gives any error. BTW , I did mention this question at the end of the thread , if you will look .

Show more comments

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

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 to make a countdown of destroyed objects ? 1 Answer

How can I make a walk animation? 0 Answers

how to make showing and hiding outline? 3 Answers

Platform should bend when object falls 0 Answers

how to make a level load after hitting a score 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