Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 fatalityfun · Jul 07, 2021 at 07:07 AM · collisionrandomdetectionspawning problemsdungeon

Trying to make a procedurally generated dungeon (3D), but rooms won't spawn

I've got the basic logic down, but I'm having trouble implementing it. My idea is that each room/piece has up to 4 spawn points attached to it that indicate where a opening or connector to another room is. Depending on the direction, they're labelled 1-4 for North, South, etc.


I have a box collider attached at the actual openings of the models to check if it's already touching another room, which would mark the opening as being inaccessible and not spawning another room.


alt text alt text

extra reference screenshots

https://imgur.com/a/YTmnpFm

much appreciated in advance!

img5.png (48.4 kB)
img1.png (228.1 kB)
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 Astrydax · Jul 07, 2021 at 07:14 AM 0
Share

Do you have rigid bodies on the rooms? IsAccessible is false until a trigger occuers and will prevent spawning. Do your objects fall into this matrix properly? https://docs.unity3d.com/Manual/CollidersOverview.html

what is "roomStock" if it's a class, it should be RoomStock (cap).

2 Replies

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

Answer by fatalityfun · Jul 07, 2021 at 10:58 PM

I found a fix for the issue. My rooms being spawned were being set to an IF statement that essentially never became true due to the setup of my world. Changing the IF statement to a WHILE loop bound to a variable that counted down each loop fixed it - even though I found even more issues later, it fixed the problem.

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 THICC_GANDHI · Jul 07, 2021 at 03:35 PM

You write isAccessible = false and the statement of your while loop checks if isAccessible is true. You get just one loop and then it stops, so only one room will spawn.

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 fatalityfun · Jul 07, 2021 at 09:29 PM 0
Share

Thank you for that, I hadn't noticed. I edited it to

     void Update()
     {
         if (openingDirection > 0)
         {
             rand = Random.Range(0, stock.roomList.Length);
             while (isAccessible == true)
             {
                 GameObject spawnedRoom = Instantiate(stock.roomList[rand], transform.position, stock.roomList[rand].transform.rotation);
                 spawnedRoom.transform.eulerAngles = new Vector3(0f, 90f, 0f);
                 if(rand <= 0) 
                 { 
                     isAccessible = false; 
                 }
             }
 
         }
     }

However, in either result no rooms spawn at all. Just the basic room I have set in the image above.

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

193 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

Related Questions

Manual Collision Detection... 2 Answers

Collision Detection When Picking Up GameObjects 1 Answer

OnCollisionEnter not working 1 Answer

Preventing circles in dungeon generation? 0 Answers

Collision detection of certain ojects 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