Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hey! Do you have an example of what would you like to achieve? The generator currently works with 2D tilemaps. You define room templates as 2d tilemaps, give it to the generator, the generator computes how to position individual rooms and then produces a level that is again composed of 2D tilemaps. I don't have much experience with 3D in Unity so I need you to help me imagine what it should do and I how would you want to use the tool.

(1 edit)

Hey, sure. The best example is Enter The Gungeon : https://twitter.com/dodgerollgames/status/593625936131653632

Actually, the levels are generated in 3D. It help about depth, lightning, and not-having-to-do-pixel-math-to-check-if-this-bullet-hit-that-thing. 

I am starting to create a roguelike based on it, among other games, and generating such a 3D world is a feature to me.

Basically, can I ouput a 3D model with its pivot point at z=0 instead of a 2D tile ? I can take care of the rest.

Thank you ! :)

I think that it's doable. There are two places you'd have to sligthly hack the generator. First, the generator need to compute the outline of each room template. To do that, it normally gets all the tilemap layers and computes the outline polygon. If you do not have any 2d tilemap, you can't rely on the default algorithm and have to do the computation yourself. There's currently a IRoomTemplateOutlineHandler interface with a GetRoomTemplateOutline() so, in theory, if you provide a component that implements this interface, you don't have to use any 2d tilemaps. The second place where additional work is needed is to handle the output of the generator. Normally, the generator does a lot of work behind the scenes in multiple post-processing steps. These steps include merging all room template into a single tilemap or disabling unnecessary colliders. The good thing is that these post-processing steps are completely optional and you can disable them all. So you'd have to disable them and then implement a custom post-processing logic. Each post-processing script is a given a mapping room -> (room template, position) and you're free to do anything with that. So you should be able to output your 3D models, it's just an additional work that you have to do yourself. So theoretically, there should be no MAJOR obstacle to achieve what you want. To be sure, I can check that there's no stupid code that for some reason expects that there are indeed 2d tilemaps used. If that were the case, it should be relatively easy to fix.

(1 edit)

That'd be great ! 

Otherwise, once the level is generated, Can I have a way to know what tile was used in a specific position ? (x=1 y=3 for example)

That way, I could write a tool that use the output of Edgar to place the 3D model somewhat "on-top" of the generated 2D level.

All I'd have to do is provide a basic 2D tilemap, and depending on the level I want to generate, provide differents 3D prefab.

That way It'd be forward compatible ?


Edit : while rereading your answer, it seems we are on the same page. If I got it right, I only proposed to still use a 2D tilemap to let Edgar "do his thing", then output via a custom post-processing logic. Am I understanding it correctly ?

Yeah, that should be possible, too.

The generator doesn't use any special data structure to store the generated level. Everything is done with built-in Unity tilemaps (https://docs.unity3d.com/Manual/class-Tilemap.html).  So if you get the instance of the Tilemap class, you can call the GetTile method to see which tile is used in a specific position. 

Example usage:
1. Define room templates as usual using 2d tilemaps
2. Let the generator create a 2d level
3. Create a post-processing script that gets access to the output tilemaps of the generator
4. Go through individual tiles in the output tilemaps and spawn corresponding 3d tiles
5. Do some cleanup (hide original 2d level, etc.)

This approach would be very close to the normal approach, just enhanced with a custom post-processing logic. One theoretical problem with this approach is its performance. The generator will compute things that are meant for 2d levels and you would then discard them and replace them with a 3d level. You should definitely avoid doing one thing - recomputing 2d colliders for the output tilemaps (assuming that you don't want them).  This is probably the most computationally demanding step. To avoid doing that, make sure that when creating room templates, you don't use any tilemap layer with colliders (https://ondrejnepozitek.github.io/Edgar-Unity/docs/basics/room-templates#designi...). Also, custom tilemap layers handlers might be useful (https://ondrejnepozitek.github.io/Edgar-Unity/docs/guides/room-template-customiz...).

Thank you for the thorough answer.

So, I bought it, I'll try to test this solution in a few days, i'll be sure to come back to you with my findings :)

Let me know if you have any problems or questions!

(1 edit) (+1)

I do actually ! 
I worked my way into the tilemap > 3D models on a grid.

What I don't seem to grasp is : how do I get the tilemap from Edgar ? 

I know it will be obvious when you'll say it, but, can you give me some pointers ? 

Thanks !

EDIT : nevermind, I found it !

I thought that, as var tilemaps = level.GetSharedTilemaps() gave me a list of six, it wasn't that. 

But the six elements are the layers used in the room templates, duh.

Will report back when I have a complete working solution.

Deleted 3 years ago