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
0
Question by Dr.frederiksen · Mar 06, 2014 at 12:51 PM · randomboxgenerator

Random box generator in certain area.

I cant get my head around this. I want to make a random box generated map,(not as in a big world of boxed stacked on top of each other). But like in the game playing with fire(look at the picture below). One layer of boxed randomly placed in a specific area. BUT i also need it to check for collision, so that it does not spawn in other things. And off cause it has to be in 3D.

The part of checking for collision is not the hard part, it's the box generator i am struggling with. It dosent matter if it is done in c# or java script. Any suggestions or tips that could help me.

alt text.

playing-with-fire.jpg (78.4 kB)
Comment
Add comment · Show 2
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 SirCrazyNugget · Mar 06, 2014 at 02:14 PM 0
Share

Create an multidimensional array to store whether each point is available to spawn or not, populate/update it by each initial spawn/placement/movement.

avatar image Dr.frederiksen · Mar 06, 2014 at 03:25 PM 0
Share

Thanks.

Thought of using arrays, just were not sure how it worked. But i checked out a tutorial on it so i will try to figure something out.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DonDeer · Mar 06, 2014 at 03:00 PM

You could make a spawnpoint(empty gameobject) on every tile the boxes are supposed to spawn at, and then make a Random.Range(1,5) and if it is 5 then spawn box.

Exsample script (for the spawnpoints):

 var spawn = 0;
 var box : GameObject;
 
 function Start ()
 {
     spawn = Random.Range(1,5);
 }
 
 function Update ()
 {
     if (spawn == 5)
         Instantiate(box, gameObject.transform.position, gameObject.transform.rotation);
 }
Comment
Add comment · Show 1 · 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 Dr.frederiksen · Mar 06, 2014 at 08:55 PM 0
Share

This sounds great, thanks for the help. I really appreciate it. :)

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

21 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

Related Questions

Random Number Generator 4 Answers

Creating a random prefab generator in C# for endless runner 3 Answers

How to create Random Stats matching the weapons? 0 Answers

Starting a roguelike, maze generator problem. 1 Answer

Generating platforms one after another 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