Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 hgabor · Aug 10, 2015 at 02:15 PM · prefabendlessstoring

What's the fastest way to store prefabs in an endless racing game?

I'm currently making an endless racing game, in which I use prefabs to generate new roads when the player car moves forward. I currently store the generatable prefabs in the prefabs themselves, and I don't think it's an efficient way to do it, and I've got a few ideas, how to change it:

  • Make a Game Object, which stores them

  • Access them from their folder, if there is a way to do it

The game also got different types of roads (like highway, city, B road), so I also got to check for it.

And if you've got better ideas, please share it!

Thank you! :)

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 DwaynePritchett · Aug 10, 2015 at 02:36 PM 0
Share

I would almost make a list or dictionary, and store them and record their number as an enum. So then you could do, PrefabList[RoadType.Highway], etc. This way you don't have to remember all of the numbers associated with the various prefab types. Also, the IDE would autocomplete that for you. So you when type, "RoadType." it will bring up the list of all the available road types. I don't know if this would be the most efficient or not. And, you can pull it from the folder, if it's within the resource folder. Look up the Resource class/functions in the documentation.

I know this isn't very specific but maybe it will give you some direction.

-Dwayne Pritchett

avatar image hgabor · Aug 10, 2015 at 03:43 PM 0
Share

Thanks, it seems like a good idea, I'll wait if others may answer, otherwise I'll do it in that way. And should I save the list in a separate GameObject?

avatar image DwaynePritchett · Aug 11, 2015 at 03:18 PM 0
Share

I think storing it in a separate game object would be fine. A type of "Game $$anonymous$$anager" of sorts.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by YoungDeveloper · Aug 11, 2015 at 03:25 PM

Create gameobject pools, idea is to maybe instantiate but almost never destroy anything. Instead set active to false unneeded gameobjects and reset active when needed. You will need to create pool manager which will hold instances of all gameobjects and their types.

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to instantiate random prefabs of varying size and rotation in a continuous track? 0 Answers

Prefab mode doesn't show prefab, still shows old scene. 7 Answers

Alternatives to iTweenPath for creating path for camera 2 Answers

Why is my prefab spawing underneath my player when facing left but not right? 0 Answers

Unity fire1 prefab in code 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