Creating random dungeon

There are no stupid questions, just stupid answers.
7 posts Page 1 of 1
Posts: 25
Joined: Thu Aug 10, 2017 12:56 am
by slapin » Mon Aug 14, 2017 3:19 am
Hi, all!

Using torque3D, what approach should be about dynamically-generated worlds, i.e. random-generated dungeon?
How can I add world parts to a scene while game is running?

Posts: 1063
Joined: Sun Feb 08, 2015 1:51 am
by Duion » Mon Aug 14, 2017 4:22 am
Easiest system would probably a grid based tile system, so you can place and remove tiles through script.
Objects can be created from script with "new TSStatic()" search for that term, in the tools folder there is a function like this to place objects in the scene already, you can copy that code.
Posts: 25
Joined: Thu Aug 10, 2017 12:56 am
by slapin » Mon Aug 14, 2017 4:53 am
Thanks a lot! Please point me where to hook a script which runs at scene load but before scene
is visible, so camera will not see how level is cinstructed?

Also is it possible to build navmesh dynamically?
Posts: 25
Joined: Thu Aug 10, 2017 12:56 am
by slapin » Mon Aug 14, 2017 4:54 am
i.e. I want dungeon monsters to navigate navmesh freely and find player without problems,,, :)
Posts: 1063
Joined: Sun Feb 08, 2015 1:51 am
by Duion » Mon Aug 14, 2017 5:37 pm
I would suggest you to get Torsion for Torquescript debugging, then you can create a breakpoint and step through the scripts and then you can decide where you hook your scripts up.
You can rebuild a navmesh dynamically, try it in the editor, for example you can select a single tile and rebuild it, you would need to trigger it ingame somehow for each tile that changes.
Posts: 7
Joined: Tue Feb 10, 2015 12:23 am
by Phantom139 » Fri Aug 18, 2017 3:51 am
Oh, this sounds like fun, and also similar to something I tested out for Tribes way back in the days of the old construction mod.

Procedural generation is reliant upon a tile set, or a list of objects from which the generator may select from. So, for your dungeon generator, you'll create a large number of tiles (Start with a small amount and branch out), including the following "bins":
  • Starting Room
  • Room (2 Doors, 1 Entry, 1 Exit)
  • Room (3 Doors, 1 Entry, 2 Side Paths)
  • Room (4 Doors, 1 Entry, 3 Side Paths)
  • Connector (Hallways if you'd rather)
  • Dead Ends
  • Exit Room
The generator itself will be coded to place each of your tiles within one of the above "bins", then the fun part. You'll have the generator start by randomly selecting a starting room tile, then randomize the number of rooms to reach the end. From here, you'll establish a selection from the connector and room bins (Randomly selecting 2, 3 or 4). When it selects a room with multiple routes, it will have another random element to decide how far it will reach away from the "designated path", and then continue branching out. Once the end is reached, select a tile from the exit room and voila.

As for the tiles themselves, this will require a bit of work on both the script side and modelling side, which is why some good debugging techniques will be required here as you'll need to get the room sizes and scales down precisely as such the flow looks good.

For generation prior to loading in, just have this occur during the pre-game time frame, or if you need it during the active game time, just have the camera at a different location with a GUI element over the screen specifying the user to Please Wait.

Navigation meshes should make use of the Recast module that Daniel Buckmaster provided to the engine a while back, you can easily detect the size of your generated dungeon and stretch a mesh over it and have Recast generate nav points for your AI very easily that way.

It's no small task by any means, but I think it will be well worth it for your project in the long term to have something like this. Good luck!
Posts: 2
Joined: Sat Aug 19, 2017 12:55 am
by Mack » Sat Aug 19, 2017 1:03 am
Gibby (along with help from the Torque community) created a Random Sequence Generator which randomly picked models from a list (without duplicates) in order to generate a randomized city environment.

Code: ... ent-855784


The same method could be applied to randomly generate any environment.
7 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests