playMaker

Author Topic: Help with procedurally generated rooms  (Read 8445 times)

bizilux

  • Full Member
  • ***
  • Posts: 171
Help with procedurally generated rooms
« on: June 04, 2014, 03:43:00 PM »
hey all

so i want to make procedural generated levels. i have a bunch of room prefabs (currently testing with only 3), right now they are all square 10x10 unity units. later on i plan to add different room sizes to this as well.

this is a bit tricky to do, since every room has either 1,2,3,4 doors for now. and they need to be rotated correctly in relation to previous room, so that doors in one room dont meet with wall on the other room.

so far i have found one solution, but i do not think its ideal... basically what i've done is:
i made FSM that has all the possible combinations of room rotations in it.
so for example when room with 1 door is at 90 degree angle, at what angle does room with 2 doors has to be. etc... all possible combinations. check this huge FSM, and it is for only 3 different room types.

  • i save current room name into string variable
  • i randomly pick next room to be spawned, and save its name into another string variable
  • i compare these two strings, and then send it off to proper state that tells it at what rotation must the room be spawned at.
i think there is more elegant and intuitive solution somewhere out there in the universe :)

i was reading this blog: http://clockworkgiant.com/procedural-dungeon-generation-in-unity3d/
and here you have some connector types... and this might be good approach too...


i could really use all the help that i can get... since i know that right approach is everything.

right now im only focusing on rotation of spawned rooms, but there is a lot more that needs to be done before this system is complete:

  • i need to incorporate array maker in it, so that it will queue which doors have rooms spawned and which dont
  • i need a system that will fill the doors with solid wall, if it detects that no room can fit in there anymore.

this is how it looks right now:


ghost010

  • Junior Playmaker
  • **
  • Posts: 51
Re: Help with procedurally generated rooms
« Reply #1 on: June 04, 2014, 04:43:09 PM »
Holy shit. thats one huge FSM.
Id love to help.but im pretty clueless when it comes to fsm's of this kind(some times a script is a better and time saving solution.)

I'll be watching this thread and see what others say.
I'll also be looking at scripts that do this and see if i can implement them into playmaker.

If i find a metode of doing so,ill share it here.
I my self am also looking into procedural levels(and a map maker solution).


Edit:
wait.. cant you just make the door have a check?
Like.If object in trigger/detector is wall,delete(or seal door)prefab and randomize for new prefab until the trigger/detector hits a door detection?
Maybe even have a "current roll"to store the wrong prefab name so it will narrow down the randomized pool?

Also(another edit) you might want to save each prefab in a xml for use with multiplayer/co-op. so that when the procedural level is done building,it can be shared over the net and other players end up with the exact same dungeon?
« Last Edit: June 04, 2014, 04:52:28 PM by ghost010 »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Help with procedurally generated rooms
« Reply #2 on: June 04, 2014, 06:22:17 PM »
yes that FSM is big, but this is just prototyping stage... once i had it figured i would had put it into multiple FSM's.

Quote
wait.. cant you just make the door have a check?
Like.If object in trigger/detector is wall,delete(or seal door)prefab and randomize for new prefab until the trigger/detector hits a door detection?
Maybe even have a "current roll"to store the wrong prefab name so it will narrow down the randomized pool?
yes yes yes. see thats why i said you only need to have the right approach :)  i was thinking something in lines of that, but i was thinking of doing it with raycasts, and it sounded too complicated. 

but a simple trigger should do it! basically at each door enterance on each room, i would have a box trigger, and then some state would check if that door trigger is overlapping with another door trigger, if it is, we are all good and new room can stay. if not, then remove new room and start again. that sounds like good workflow right? or you thought of some better workflow?

i also like the idea of having current roll, so that it narrows down randomized pool, but wouldnt that be like really hard to make? it sure seems so right now.

Quote
Also(another edit) you might want to save each prefab in a xml for use with multiplayer/co-op. so that when the procedural level is done building,it can be shared over the net and other players end up with the exact same dungeon?
oh yes i also like this idea, i do not know much about how to make it, but i like the idea.


do you want to know why im doing this?

im basically doing procedural FPS tutorial series. possibly multiplayer too. sort of like something that first wolfenstein 3D game was.

and yes it will be paid, since it will be huge, i reckon atleast 8+ hours of video content.

i plan on having all this stuff in and more, at a rather small price. (under $100)
  • procedual rooms and arraymaker implementation
  • sliding doors
  • enemies AI. as complex as i can make it within playmaker
  • AI turret system
  • shooting and different types of guns
  • health system
  • sounds
  • statistics (end of level screen)
  • saving/loading of the game
  • difficulty settings
  • saving/loading of generated levels with XVM
  • minimap/map?

im also looking for partner with this, since this tutorial series is so huge!
« Last Edit: June 04, 2014, 06:24:12 PM by bizilux »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Help with procedurally generated rooms
« Reply #3 on: June 05, 2014, 06:27:43 AM »
i think i thought of a better system.

each room will have empty game object (placeholder) at door entrance, named door 1, door 2... etc.

and then what i will do, is i will just spawn next room on top of lets say door 2. and then check for collisions, if that room is overlapping with some other room, i will delete it and try again.


edit:

i think i might have hit a small bump...

does anyone know, is there a way to update pivot points at runtime?

because i do not need pivot point to be at the center of the room, but i want it to be dynamically changed to whatever door im placing it at... so i can rotate room.

if that is not possible, then i will just have to make a lot of 3D models of same rooms, but different rotations.
« Last Edit: June 05, 2014, 07:30:26 AM by bizilux »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Help with procedurally generated rooms
« Reply #4 on: June 05, 2014, 11:58:58 AM »
You could parent the room to an empty GameObject and rotate that - allowing you to control the pivot point.

Interesting project :)

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Help with procedurally generated rooms
« Reply #5 on: June 05, 2014, 12:55:38 PM »
You could parent the room to an empty GameObject and rotate that - allowing you to control the pivot point.

Interesting project :)
yep interesting... but not easy :) its quite challenging for my mind :) really need to think hard, hehe. but when it finally works, its so rewarding :)


yes that is what i have been doing for past few hours... it is looking good.

this is what i have right now :)
« Last Edit: June 05, 2014, 01:12:41 PM by bizilux »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Help with procedurally generated rooms
« Reply #6 on: June 05, 2014, 03:21:48 PM »
this is where im at now:



im only spawning one room prefab right now, the one with 4 doors.  i wanted to do this first. and now i have to incorporate arraymaker i believe...

i barely used arraymaker in the past, so not that experienced with it :)

the thing is: now i randomly pick one door from newly created room, and spawn new room there, and then go on to next room. so right now, 2 doors always stay opened.

and now i want to make array, that will add doors to array. and then remove doors from array, once room is spawned there.

i think that shouldnt be that hard to accomplish :)



EDIT:


arraymaker working as expected

next stop... adding other room prefabs to the mix, and seeing how it all comes together and where i need to fix things.

« Last Edit: June 05, 2014, 06:14:51 PM by bizilux »

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Help with procedurally generated rooms
« Reply #7 on: June 06, 2014, 09:39:20 PM »
ok so now i added quite a bit of room variety to it

the only problem is that right now is whole generation is "single threaded". meaning that only 1 FSM is in charge of spawning and checking if room fits. this picture below is after 15 minutes of running. (there are around 250 rooms spawned)

tomorrow i will make it multi threaded, so that when room is spawned, that room will take control over its doors, and spawn rooms there, if available. and i believe that will speed up generation process alot.

i will also start some new thread somewhere where i will be posting this little updates. cant keep on bumping this thread :)


1982

  • Junior Playmaker
  • **
  • Posts: 71
Re: Help with procedurally generated rooms
« Reply #8 on: June 07, 2014, 03:45:33 AM »
tomorrow i will make it multi threaded, so that when room is spawned, that room will take control over its doors, and spawn rooms there, if available. and i believe that will speed up generation process alot.

When I tested procedural generation with PM, that is how I did it. Every room had it's own logic what do after it was spawned to scene.

Anyway interesting project, truly shows how powerful and capable PM is :)


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Help with procedurally generated rooms
« Reply #9 on: June 07, 2014, 10:01:44 AM »
Quote
i will also start some new thread somewhere where i will be posting this little updates. cant keep on bumping this thread :)

I would keep it here - it's fascinating seeing the evolution in one thread :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Help with procedurally generated rooms
« Reply #10 on: May 30, 2016, 11:37:08 AM »
Hi,
Is this Tutorial cancelled?
If so you you still have the project somewhere?
I am very interested in this.