Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Nov 16, 2015 at 06:57 PM by Gersio for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Gersio · Nov 09, 2015 at 12:58 PM · arrayslistsdroptrackbest practices

Multiple scripts vs arrays vs lists?

HI everyone!

I'm developing a mobile game where you can tap on trees to get a fruit drop or use an axe to chop them and get some wood. If you chop a tree, it then starts growing again. Every tree has to store it's own time variables like "lastTimeDrop" and "timeLeftToGrow" so I can check if the tree has grown or if it can give the player another drop.

My problem is that I don't know which is the best aproach to handle all the trees. Should I have an array with all my trees and other arrays with their varaibles and check them all every second? Should I use Lists? Is better to have every tree with a script (same script for all of them) ? Any help will be apreciated!

Also, how can I track every tree between game sessions to know which tree has grown, which tree can drop something, etc.?

Thank you very much for your time,

Sergio

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 meat5000 ♦ · Nov 16, 2015 at 11:51 AM 1
Share

This is a wide question. You should research and experiment to find the answer.

I will advise you to not check the status of every tree every second. Its not that time critical so you should save on processing.

Consider groups of trees with a Tree-$$anonymous$$anager LOCAL to the group. This will help prevent needless processing. Dont have 1 manager for every tree or each tree handling their own.

Just my opinion, but that is exactly why this should be on the forum and not on UA :)

avatar image KazYamof · Nov 16, 2015 at 04:25 PM 0
Share

Totally agree with @meat500. I use the approach to have "$$anonymous$$anager" to manage a group of items, and a "Controller" to manage a single item of the group. Some things like animations and stats I like to have individual, but some others makes more sense to have a group manager to deal with. $$anonymous$$ake some tests

avatar image Gersio · Nov 16, 2015 at 06:56 PM 0
Share

Hey! Thank you both for your time! I'll follow your advice and make some tests to see what's better. And you're right, this could lead to a further discussion more proper for forums haha

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

reference the name of each texture in a texture list as a string array for PlayerPrefsX.SetStringArray 0 Answers

creating and manipulating a grid efficiently 1 Answer

What is the maximum amount of objects that can be stored in an Array or List without causing any error? 1 Answer

How do you put a List under an Array item (Hard time explaining) 1 Answer

Enemy AI to Discover Waypoints 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