OndrejNepozitek / Edgar-Unity

Unity Procedural Level Generator
https://ondrejnepozitek.github.io/Edgar-Unity/docs/introduction
MIT License
817 stars 70 forks source link

How to close off dead end? #47

Closed longtran2904 closed 4 years ago

longtran2904 commented 4 years ago

I saw in the examples that your rooms was tight (all the outlines have tiles) and when the corridoors connect to it, it would disable the tile at the door's position. I didn't use corridor in my game (it was a 2d side scroller) so how could i achived this? While I testing by having tiles at door's position i noticed that if the room was generated first it would disable the tile at the connection, if not it wouldn't.

OndrejNepozitek commented 4 years ago

Can you please show me an example of a room template from your game?

longtran2904 commented 4 years ago

This is before; image

This is after: image

I just want to close off dead end so i thought the generator would automated removed the tiles P/S: The door's mode is specific and the position is at the 2 tiles up and below

OndrejNepozitek commented 4 years ago

If I understand your goal, I'd the the following. In your room templates, add wall tiles to all your door positions. And then create a special corridor room like in the image below. The width of the room is 4 tiles, the height is 2 tiles. Black are walls, red is one door position, pink is another door position (and there should be your purple background tiles under the doors).

image

The only purpose of this corridor room is that it will correctly connect two adjacent rooms. So it is not really a corridor, but rather a connector. And by using this corridor, your dead ends will be handled automatically, because if there is not adjacent room, there will be no corridor and the room will look like in your 'after' picture.

If you need also a connector in the horizontal direction, just create another corridor room, this time width 2, height 4 and just rotate the design.

Then assign these corridor room templates to your level graph and enable corridor.

Let me know if that works for you.

longtran2904 commented 4 years ago

It keep having this error: InvalidOperationException: Timeout was reached when generating level The error is happened in: DungeonGeneratorPipelineConfig And what layer should i draw the corridoor? Here is the picture (i also made a horizontal one): image

OndrejNepozitek commented 4 years ago

This is quite strange. Can you please check that if you disable corridors now, everything works as before?

Also please check this:

longtran2904 commented 4 years ago
  1. If i disable corridors it still worked fine
  2. I was testing so there were 6 rooms
  3. 10000
  4. I also did that
  5. Yes, i don't change anything
longtran2904 commented 4 years ago

Maybe because the layer that i drawing? Does the tilemap layers matter?

longtran2904 commented 4 years ago

Here is the entire debug text: InvalidOperationException: Timeout was reached when generating level Assets.ProceduralLevelGenerator.Scripts.Generators.DungeonGenerator.PipelineTasks.DungeonGeneratorPipelineTask1+<Process>d__0[TPayload].MoveNext () (at Assets/ProceduralLevelGenerator/Scripts/Generators/DungeonGenerator/PipelineTasks/DungeonGeneratorPipelineConfig.cs:72) Assets.ProceduralLevelGenerator.Scripts.Pipeline.PipelineRunner+<GetEnumerator>d__1.MoveNext () (at Assets/ProceduralLevelGenerator/Scripts/Pipeline/PipelineRunner.cs:144) Assets.ProceduralLevelGenerator.Scripts.Pipeline.PipelineRunner.Run (System.Collections.Generic.IEnumerable1[T] pipelineItems, System.Object payload) (at Assets/ProceduralLevelGenerator/Scripts/Pipeline/PipelineRunner.cs:18) Assets.ProceduralLevelGenerator.Scripts.Generators.DungeonGenerator.DungeonGenerator.Generate () (at Assets/ProceduralLevelGenerator/Scripts/Generators/DungeonGenerator/DungeonGenerator.cs:79) Assets.ProceduralLevelGenerator.Scripts.Generators.DungeonGenerator.Editor.DungeonGeneratorInspector.OnInspectorGUI () (at Assets/ProceduralLevelGenerator/Scripts/Generators/DungeonGenerator/Editor/DungeonGeneratorInspector.cs:63) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass55_0.b__0 () (at :0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

OndrejNepozitek commented 4 years ago

Can you please also show me how the second corridor looks like? Also if you're willing to just zip your Assets folder and send me the project, I can look into that myself.

The error itself is unfortunately useless. It just shows that the underlying algorithm is not able to generate a layout, which really should not happen with such a simple setup.

OndrejNepozitek commented 4 years ago

Oh, I just remembered that there should be a built-in export for the input of the algorithm. In the Generator component, there is an "Advanced" section with a "Export map description" button. Please click the button and it should create a json file in the root of your project. If you send mi the file, I can try to find the problem.

longtran2904 commented 4 years ago

image

longtran2904 commented 4 years ago

Github doesn't support json so i send the txt exportedMapDescription.txt

OndrejNepozitek commented 4 years ago

Okay, thanks. I might know where's the problem. The doors mode of corridors must be "specific" and you must draw the door positions yourself. It seems like you used the simple mode with door length 1. And there was therefore a mismatch if door lenghts. I shoud have been more clear when describing the setup.

longtran2904 commented 4 years ago

Yes that's fix the problem. Thanks!