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 john-essy · Apr 18, 2011 at 12:24 PM · guicount

Collect and through

Hi there and thanks for looking the problem i am having is i am trying to write a script so that i can collect an object so the script counts how much of that thing i have then when i through it it deducts it from my script also with a gui write so that it adds it in the gui and subtracts it but i don't know how to go about writing that i thought maybe i could use the fps ammo count but doesnt seem to work.

This is the last thing i need for my game mechanics i have got my AI scipts working lives and hits and no this isn't a tornado twins type game lol usually have a scripter but he is on holiday please help guys

if you need any more info please help as this assignment needs to be handed in in three days

Comment
Add comment
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
0
Best Answer

Answer by Jesse Anders · Apr 18, 2011 at 02:02 PM

Why no capitalization or punctuation? :|

(Well, to be fair, there is a capital letter at the beginning of the first paragraph and a period at the end of it, but nevertheless it's still a little difficult to read ;)

Anyway, here are some suggestions based on what I was able to glean from your post.

  • Look into colliders, triggers, and callback functions such as OnTriggerEnter() for determining when a 'pick-up' item has been collided with.

  • Store the number of items collected in a variable of type 'int'.

  • In an OnGUI() function associated with the same script, use GUI.Label() or GUILayout.Label() to display the item count. You can use int.ToString() to convert the count to string form for display purposes.

You mentioned deducting and subtracting, so it sounds like there's more going on than simply accumulating items. If you need more help though, we might need some more details about what you're trying to do.

Comment
Add comment · Show 2 · 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 john-essy · Apr 24, 2011 at 09:41 PM 0
Share

Thanks. What i am trying to do is. When the player collides with an object (Let's say a bottle). A script counts how many bottles i have and gives me points for collecting the bottle. Now when i throw the bottle it deducts that from how many i have collected and when i am at 0 no more bottles can be thrown. Also when i collect a bottle i would like it so that there is some picture at the top left of my screen that displays how much i have left not just text but with images

avatar image Jesse Anders · Apr 25, 2011 at 08:18 AM 0
Share

What you describe has about 4 or 5 different aspects to it (picking up items, keeping track of them, throwing items, displaying the current number of items graphically, etc.). What I'd recommend is tackling one problem at a time, and then asking about each problem separately here or on the forums as needed. For example, you could start with the 'picking up an item' part (for which you'd probably use a trigger collider and OnTriggerEnter()). If you have problems with that part, I'd recommend posting to the forums (it might be a little easier for people to help there).

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

How to increase score on hit 0 Answers

adding ammo count 2 Answers

make it create GUI copy per count. 0 Answers

Help for shots in a script 2 Answers

Count objects with a certain tag and display number on GUI 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