• 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 Fireking883 · Apr 04, 2016 at 07:24 AM · javascript

Getting data for if an object has already been collected on startup

I am attempting to create a method of saving whether a stone has or has not been collected in my scene on startup. I have done everything I know to do with playerprefs, but the playerpref is for every resource, as there will eventually be a lot of stones. What I want is, if you collect a resource of any kind, including chopping down a tree, picking up a stick, or destroying a bush, to 'know' if it has already been destroyed when the game starts up, and for it to destroy itself if it has... and the only way I know to do this is to create a playerpref for every single collectible thing in the world, which there is a lot of. Thanks for any help!

Comment
Add comment · Show 6
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 ♦ · Apr 03, 2016 at 10:20 PM 0
Share

This kind of idea uses voxel engines these days.

https://www.google.co.uk/search?q=voxel+engines+unity&ie=utf-8&oe=utf-8&client=ubuntu&channel=fs&gfe_rd=cr&ei=spYBV-qEJ5CFa$$anonymous$$acsJAF&gws_rd=ssl#channel=fs&q=voxel+engines+unity+resource+management

Chunk management etc

They are good at condensing the amount of data so you dont need 1 entry for each item.

avatar image b1gry4n · Apr 04, 2016 at 11:39 AM 0
Share

Ive never tried this so I am just spitballing here...

Couldnt you just add a playerpref for only the objects that have been picked up rather than storing information for each rock?

Is your world generated at runtime? Theres multiple approaches you can take to getting these rocks into a list of some kind. If they are generated at runtime, when those rocks are placed add them to a list. If the world isnt generated at runtime, creating a "rock manager" script could be achieved by parenting every rock in the game to a single gameobject with this "rock manager". Hopefully your hierarchy is organized enough to be able to click the top most rock and +shift click the bottom rock to select them all, then drop them into the "rock manager" list.

When a rock is picked up, tell the rock manager. Rock manager finds that rocks position in the list and a playerpref could be created (rock at position 52 in the list has been picked up). When the game loads, have the manager to a save check that finds rock 52 and turns him off.

avatar image Fireking883 b1gry4n · Apr 05, 2016 at 12:47 AM 0
Share

Someday I probably will look into making the worlds randomly generated, or at least the rocks, but currently I am just experimenting with rocks that I place...

avatar image b1gry4n Fireking883 · Apr 05, 2016 at 08:02 PM 0
Share

getting them in a list some how (either manually dragging and dropping or whatever), saving the spot in the list for rocks that have been picked up, and removing the rocks at that list point with list.RemoveAt(x) on load would be the approach i would take.

Show more comments
avatar image Fireking883 · Apr 06, 2016 at 02:35 AM 0
Share

Thanks for the help! I will work on getting that to work when I get home.

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.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

BCE0019 "enabled" is not a member of "Object"(On JavaScript Script) 2 Answers

Can't attach an script 0 Answers

Need help with game points and trigger 2 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