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
1
Question by The Corporal · Nov 04, 2010 at 01:27 AM · build3drandomspawnspawning

How to spawn random buildings

Noob here trying to figure out Unity...

So I need a way to make slightly random buildings appear (different roof combinations, etc.) and with certain boundaries on where they spawn (not more than X units away from Building A) This is not for a background, so it needs collision.

Any ideas?

Comment
Add comment · Show 1
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 The Corporal · Nov 04, 2010 at 03:18 AM 0
Share

Thanks for the help, guys. In case you were wondering, I'm making a clone of Canabalt.

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Atnas1010 · Nov 04, 2010 at 01:32 AM

Make the different building elements in some modeling software.

Instantiate them randomly with scripts.

Or build the city manually, and accept that it is always the same.

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

Answer by Loius · Nov 04, 2010 at 03:28 AM

The particular functions you'll want to investigate are

Instantiate( Resources.Load("AResource") )

Random.value

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

Answer by QueenMab051 · Nov 04, 2010 at 02:56 AM

I agree with Atnas. Your best bet would be creating the buildings and roofs as seperate models in a modeling program like 3ds Max (which you can get a free 30-day trial of), importing them into your Unity project, then using scripts to randomly select and spawn said models.

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

Answer by Herman-Tulleken · Nov 04, 2010 at 06:58 AM

A very simple solution might be to use a jittered grid for spawning buildings, especially if they are roughly the same size. See this link for information:

http://umbcgaim.wordpress.com/2010/06/17/distributing-stuff/

And here is an interesting paper on random point generation (which could be helpful for spawning buildings too):

http://jenny.cartography.ch/pdf/2010_Jenny_etal_PointPatternSynthesis.pdf

And this could be helpful for generating non-regular grids:

http://gram.cs.mcgill.ca/papers/rudzicz-08-iterated.pdf

Here is some more information on procedural city generation which might find helpful. (It might be overkill for what you are trying, but the ideas are interesting and you could probably simplify or adapt it for your needs):

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.91.8713&rep=rep1&type=pdf

http://ccl.northwestern.edu/papers/ProceduralCityMod.pdf

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.92.5961&rep=rep1&type=pdf

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

Answer by jasperstocker · Apr 04, 2014 at 02:30 AM

Check out my asset BuildR for generating Buildings at runtime or in the editor.

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

1 Person is following this question.

avatar image

Related Questions

How do I make a game object spawn several times in semi-random locations? 1 Answer

Enemies spawn on top of each other(C#)(Unity) 1 Answer

Instantiate Random 3D Objects/platforms that dont overlap 1 Answer

Distribute terrain in zones 3 Answers

AI spawning areas. What are the ways to make them? 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