playMaker

Author Topic: Generate Room: Empty space checker  (Read 3041 times)

Sly

  • Full Member
  • ***
  • Posts: 124
Generate Room: Empty space checker
« on: January 22, 2015, 12:15:46 PM »
Hello,

I'm actually working on how to generate randomly my dungeon.
I recently read this topic:
http://hutonggames.com/playmakerforum/index.php?topic=7522.0

It was very interesting (And I thank bizilux for shared with us).

But now I'm working on how to check what space is available in front of my room. And so, being able to spawn a new room with correct size for fitting into this empty space.

But I really have trouble to being able to check what's available in front of my room.
-I try with spawning a grid (Picture A) I don't know how the retrieve the result.
-I try with Raycast (picture B) --> it's not very precise and let error gap
-I try with Multiple Raycast (Picture C) Like you can see on picture, the result is not correct. The calculation method has error.

Do you have any ideas, suggestion on how to detect space in front of my room? How I can do that? Am I missing something?

Thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Generate Room: Empty space checker
« Reply #1 on: January 22, 2015, 12:53:54 PM »
The way that DunGen approaches the issue is by creating Doorway points that face outward from the room. Where there is a Doorway point then there can be a new module created with one of its Doorways also at this same location. Then all it needs to do is rotate the room to make the Doorways to face each other and do a collision check to see if the room is hitting other rooms. The weirder the room shape, the more often this fails.

If you're trying to create hallway connectors between the rooms then maybe you can define some spacing/snapping rules, then create prefabs depending on the gap between Doorways. I'm not really sure how your current method is supposed to work toward doing what seems to be what you're working toward.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Sly

  • Full Member
  • ***
  • Posts: 124
Re: Generate Room: Empty space checker
« Reply #2 on: January 22, 2015, 02:06:53 PM »
Hello Lane,

I'm actually using the door system (kind of). All the arrows you can see on my screenshot are "ExitPoint". For our room, it take one randomly, choose randomly an other one and rotate the new room by the exit point (so the pivot is in the correct direction). Basically the two room are in front of each other.

After that I can do a collision check like you said. But I'm scare it could be stuck or take a ton of time (bizilux told us it could take 5min using this :/)
So I'm trying to find a way to anticipate this, and that's why I'm trying to do a "SpaceChecker".

My rooms are not standard shape, and I don't want to be limited. I want to:
-Find out a way to know what is the size of the free space near the room -Randomly spawn a room regarding the free space size.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Generate Room: Empty space checker
« Reply #3 on: January 22, 2015, 02:19:09 PM »
What are you considering "Free space" to actually be?

If you're thinking about a Raycasting approach then that might work but wouldn't be any better than doing a collision check, likely slower and less reliable actually.

It seems to be that the best way would be to just stick a bounding volume for each room and check for a collision against the layer that the modules are on after you create it. Thats basically what DunGen does and its super fast. The failed event could generate a lot of slow down, though, if it continued to attempt creating a room in a specific spot but it failed to do so thousands of times.. Debugging with Breakpoints would be easy to track that down with.

I can't see creating any dungeon of reasonable size taking 5+ minutes...
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Sly

  • Full Member
  • ***
  • Posts: 124
Re: Generate Room: Empty space checker
« Reply #4 on: January 22, 2015, 03:12:14 PM »
By "Free space" I mean not occupy by any object with the Tag "Room".

Yes, I agree with you, the raycast method is kind of good but not precise, so it can make weird things.

I agree too with you about the collision check. But I'm always scare to let the dungeon creation being stuck for a moment.
That's why I was curious to see if other ways were possible.

I checked DunGen and it's a fast generation because all rooms have the same shape (a square). So the generator is always checking the same collision size. In my case rooms and corridor don't have all the same size.

I attach a picture of what I want to have.
The only thing missing is how to have the size of the available space.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Generate Room: Empty space checker
« Reply #5 on: January 22, 2015, 03:26:43 PM »
When would that situation actually occur though? Maybe you're designing something that doesn't really need to be designed when you consider the actual flow of the generator.

In DunGen I created all kinds of wonky room shapes. It makes a rectangular volume of estimated size for each room to use internally when looking for overlaps during placement. If you want extremely dense dungeons then you are going to have to figure out how those doors and rooms are going to be connecting after you make these weird shapes in weird places with doors that are out of alignment. After you look at the bigger picture and desired result this might not really even be an option.

Maybe if it fails the collision check it just tries smaller rooms there until it reaches the smallest one and finally decides nothing will fit? You would have to define rooms by size for this method, but thats not a big deal.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Sly

  • Full Member
  • ***
  • Posts: 124
Re: Generate Room: Empty space checker
« Reply #6 on: January 22, 2015, 04:25:37 PM »
I try to anticipate situation, even the weird one. But like you said, I need to think about if it will really happen.

For the door connection it should be alright. I not necessarily need to have direct door from door to door. A corridor could do the job in some situation. After the map is generated, I think to check all non-connected door.. Anyway it should not be a big deal.

And yes, I want to try to do a dense dungeons.
I like your idea about spawning smaller and smaller room if collision check fail. It could be a thing to try.

Thanks for your help Lane, it's very appreciated. I will keep searching in different way to do that.