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 Mar 30, 2020 at 11:20 PM by Ultronium for the following reason:

Project abandoned.

avatar image
0
Question by Ultronium · Mar 28, 2020 at 10:13 AM · instantiateterrainprefabinstantiate prefabprocedural generation

Instantiate prefabs next to each other?

Hello. I have to achieve an endless driving game. I need to learn how I can instantiate ground prefabs and have them randomly generate right next to each other when the player is close to the edge of the current ground prefab so the gameplay is endless.

Input is much appreciated. Thank you.

Comment
Add comment · Show 5
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 sacredgeometry · Mar 29, 2020 at 01:24 PM 0
Share

Unfortunately that way wouldnt be endless because the world is limited in size so you would have to factor that in and transport the player back to the preceding edge of the world space.

What kind of driving game is it? That will dictate the best way to achieve it. Things like being able to do U-turns or reverse in the level etc. will also dictate the best way to achieve this.

Can you give us a little more information please?

avatar image Ultronium sacredgeometry · Mar 30, 2020 at 02:19 AM 0
Share

Hello SacredGeometry. Thank you for taking the time out to reply. I do realize that the world would be limited in size and that the player would have to be sent back. But, considering the nature of the game, none of that would be a problem. I also agree that I might have worded the question wrong and it isn't necessarily a procedurally generated world that I'm looking for but rather a series of randomly instantiated prefabs to create a game level that won't repeat itself. The best game as a reference that I could find is PAKO Forever. You can see how the player gets sent back to the start as soon as they crash. That's essentially how I want it to be. Could you please drop in your two cents on how I can potentially instantiate prefabs at random next to eachother?

avatar image sacredgeometry Ultronium · Mar 30, 2020 at 07:29 AM 0
Share

As I pointed out you need to outline the nature of the game or be more specific about your problem.

Providing each piece is the same size and I would advise you make it standardised to save yourself problems. Instantiating prefabs next to each other is literally just a matter of multiplying the size of the prefap in the axis you want by an incrementing number.

Will that be the best solution for all games No.

So be specific. You may want to keep the player still and have a buffered rolling floor ins$$anonymous$$d.

We cant advise you unless you explain what your game is and how you intend it to work.

avatar image tormentoarmagedoom · Mar 29, 2020 at 01:32 PM 0
Share

Hello.

You are not asking about a function or something specyfic. You need to learn the structure, the basic the methods first... You need to go learn with some of the 10000 youtube tutorials about precedural developing. IF dont get one function or method to work, then come here to ask for that specyfic thing.

Bye"

avatar image Ultronium tormentoarmagedoom · Mar 30, 2020 at 02:22 AM 0
Share

Hello Tormento. Thank you for replying. I do agree I need to learn a lot more about procedural generation and this is far from what a true procedurally generated world would be but I do need help with something amongst these lines about spawning prefabs next to eachother at random. Do you think I should use triggers to spawn in a nearby ground prefab for when the player is about to reach the end? Thank you.

1 Reply

  • Sort: 
avatar image
0

Answer by twrabetz · Mar 30, 2020 at 02:26 AM

You'll want to look Object Pooling in order to efficiently recycle your ground tiles. If you try to instantiate objects constantly it will be inefficient.

A random generation scheme for your tiles could be done in a lot of different ways. Maybe make a list or dictionary of your tile types and pick a random element to choose which tile to place?

Comment
Add comment · Show 2 · 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 Ultronium · Mar 30, 2020 at 03:27 AM 0
Share

Insightful! Thank you! I'm looking into object pooling as we speak. $$anonymous$$uch appreciated.

avatar image twrabetz Ultronium · Mar 30, 2020 at 12:35 PM 0
Share

Also as other people have mentioned, if you go too far out into the world, it becomes an issue. One good solution is to just move the ground, and always have the player stay still. Another is after the player has traveled a long distance you can teleport then back to the origin.

Follow this Question

Answers Answers and Comments

196 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Terrain: Use as scenario (individual) and prefab (unchanged, reusable) 0 Answers

My objects instantiate at a strange z coordinate 0 Answers

How to instantiate particle effect after destroying it 2 Answers

Instantiating multiple objects, Destroying and instantiating on trigger + delay 0 Answers

How to instantiate a projectile only from the weapon prefab of the firing player? 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