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 DevMerlin · Feb 26, 2013 at 05:46 PM · arraylistindex

What type of array should I use to handle a convoy?

I need to keep track of members in a convoy guided by the player, that can be destroyed or added to per game conditions. I was using a standard List, but that has proved inefficient as it is Linear, and if an object in the List goes Null, it can't adjust without a lot of extra code. However, to determine positions in the convoy I also want to use an Index. Can anyone offer suggestions?

Comment
Add comment · Show 3
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 Tarlius · Feb 26, 2013 at 06:00 PM 0
Share

I think you're stuck between a LinkedList and a list, each with their own drawbacks. How big will your convoy be, how often will you need to alter it, and how will you access it? Those will probably be what drives the decision, although if its small values it probably won't make a noticeable difference anyway. $$anonymous$$aintaining an index will involve some kind of insertion/remove logic however you do it I think :/

avatar image DevMerlin · Feb 26, 2013 at 06:06 PM 0
Share

I was thinking of a LinkedList but I need to ensure that the player always remains in position 0, and enemies can target convoy members. At worst the array will hold just five objects - fairly small. It's also used for convoy members to track each other.

avatar image Tarlius · Feb 26, 2013 at 06:22 PM 0
Share

If you know the max size of the array, you can specify the size of the internal array when you initialise the the list. But I think you're worrying too much, to be honest. You time would probably be better spent worrying about something else. Or sleeping :)

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.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

How do I return the index of an array of sprites as an int? 1 Answer

How do I check a List[0], when it's nothing? 1 Answer

Find specific element when duplicates exist in list. 1 Answer

List gives "Array index is out of range" for no reason 2 Answers

How do I find a local variables index in a foreach loop? 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