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 Savage_Newb · Mar 11, 2014 at 09:59 PM · proceduraltreegenerationdungeon

BSP Tree for dungeons generation, HELP!

Hi,

I've been trying to implement the principles on this article in Unity: http://www.roguebasin.com/index.php?title=Basic_BSP_Dungeon_generation

The code for the class is here: http://pastebin.com/myC3YpM1

The result for only parsing left rooms is here: http://imgur.com/f63BSRv,Ve4Ac0P#0

The result for only parsing the right rooms is here: http://imgur.com/f63BSRv,Ve4Ac0P#1

At first I tried to parse every leafs and implement the whole thing. I quickly found myself in debugging hell. So I decided to start by always splitting on the same axis at half the size for every cut. That way I could tell if something was going wrong.

It would appear I have a problem for my rightRooms as you can see on the result image. We can clearly see that there is a problem when it goes deeper than 2 cuts and start to take too much space an overlap with other cuts.

Debug.Logs for the rightRooms:

http://imgur.com/4fdsIIW,ChYxkTO#0

http://imgur.com/4fdsIIW,ChYxkTO#1

I would really appreciate any help I can get. I tried looking up more on BSP Trees but the only thing I could find is not related to dungeons generation.

Thanks in advance.

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 Jamora · Mar 13, 2014 at 07:16 AM 1
Share

After a quick code review, shouldn't

 this.leftRoom = new BSPRoom(this.start, new Vector2(split, this.end.y));

actually be

 this.leftRoom = new BSPRoom(this.start, new Vector2(start.x+split, this.end.y));
avatar image Fattie · Mar 13, 2014 at 07:28 AM 0
Share

"psychic Jamora on the case" ;-)

avatar image Savage_Newb · Mar 14, 2014 at 10:45 PM 0
Share

@Jamora hmm how could I have missed that... After adding your mod I could remove the "width/height +=" in the DrawFloor.

Result so far: http://newbiverse.com/unity/bsp.html

Thanks again :D

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Savage_Newb · Mar 12, 2014 at 11:12 PM

I made progress testing certain things out. I decided not to "render" the leftRooms and then I was just left with 1 cube being displayed and it was in the proper size, which lead me to believe that it was actually the leftRooms that were not being rendered properly.

I removed the Mathf.Abs in the function DrawFloor and added the following:

 if (width < 0) {
    width += this.start.x;
 }
 if (height < 0) {
    height += this.start.y;
 }

After that I re-enabled the render of both rooms and also the parsing of both rooms and I got some much better results without any overlapping. If I put the random axis cut everything is also okay. But when I cut sections at random sizes I get some missing sections.

So still a few bugs but i'm progressing :)

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 Fattie · Mar 13, 2014 at 07:27 AM 0
Share

That can be a lot of work man! We have a full "procedural castle" generator we built up for a client, it can take man-months of work. BTW a very simple improvement to that algorithm, just, simply, randomly add about three (in the example) connections between adjacent rooms; it just mixes it up a bit. Good luck!

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

23 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

Related Questions

2D Tilemap room prefabs for dungeon generation. 0 Answers

How would I change my procedurally generated map change cells if it detects cells are around it? 0 Answers

Procedural generation of dungeons with rooms made in the new tile map system? 0 Answers

Procedural Random Walk Dungeon Generator? 2 Answers

creating a mesh procedurally 4 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