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 Cjmarkham · Jul 08, 2014 at 11:16 AM · gameobject

Collecting game objects in specific order

I have some objects that need to be collected. Each object has a number assigned (1,2,3,etc).

How would I go about making sure these objects are collected in the order they are numbered?

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 HarshadK · Jul 08, 2014 at 11:23 AM

The logic for such a situation will go as below:

  • Set an integer variable for last collected item like lastItemCollected.

  • Then when user tries to collect an item check if that item is lastItemCollected+1.

  • If yes then add that item to your collected items list and update the value of lastItemCollected by one.

  • If not then do not allow to collect that object.

You need to tweak this logic to suit your needs. :-)

Comment
Add comment · Show 4 · 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 Cjmarkham · Jul 08, 2014 at 11:41 AM 0
Share

Thanks for that, it worked well. However, quick question on topic. What if I need to get the next game object after picking one up?

avatar image HarshadK · Jul 08, 2014 at 11:43 AM 0
Share

Not quite sure as to what you are asking. Can you elaborate.

avatar image Cjmarkham · Jul 08, 2014 at 11:48 AM 0
Share

Its basically for an arrow system which points to the next game object. So when you collect the first one I need to get the position of the second one so the arrow can point to it. Just not sure how to get the next item.

avatar image HarshadK · Jul 08, 2014 at 11:52 AM 0
Share

You can find the next game object of current object by using the GameObject.Find() considering the name of the game object has the number which you need to collect. Then get the position of that game object using gameObject.transform.position.

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

2 People are following this question.

avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

C# Check If Gameobject is within Collider 1 Answer

C# Preserving GameObjects' Previous Meshes 1 Answer

Player instantiates Backwords 0 Answers

increasing speed and time of spawn game object 0 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