Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hey, just discovered this superb level generator! Trying to make it work with 2d lights and shadow casters and have run into some problems where halls/doors are connecting to the rooms., as in the screenshot in this link image

The way I've done it right now is to add shadow casters to the wall object in the room templates (also other object in the room template when i needed more than one shadow caster). It's When the hallway templates connects to the door positions that the shadow intersect.

I can kind of get around it by only adding a few door positions, and make several shadow casters that do no overlap them, but that severely limits the amount and size of door positions that i can use.

Do you know of a way around this?

Hello, unfortunately, I have no experience with 2d lights and shadow casters in Unity. But maybe one thing that could help would be to not have these shadow casters attached to the Wall tilemap in individual room templates but rather have them attached to the shared tilemaps where all the room templates are merged into.

After a level is generated, I find all the tiles in individual room templates and combine them into a set of shared tilemap layers. That means that walls from all room templates are merged into a single large tilemap layer. What I propose is to not add shadow casters to walls in room templates but rather add them to the shared tilemaps where corridor connections are already processed. You can first try that manually: generated a level and then inspect the game object in the scene hierarchy, find the shared Walls tilemap layer and add the shadow casters.

I’m not sure how much experience with Edgar you have so feel free to ask additional questions. I may also try these shadow casters myself if you give me some additional instructions on how to do that.

(1 edit)

Thanks for your quick reply. You mean in for instance add it to Generated Level>Rooms>Walls?

While that probably would work on an existing level, but since you have to define the shape of the shadow caster manually (at least from what I know), it would not work in practice.

I was thinking it might work if you could add it directly to a single tile, then when you fuse corridors with rooms you could remove the shadowcasters from the colliding room tiles. No idea how to add it so a single tile though.

If you could somehow generate a Shadow caster that has the same shape of a shared wall tilemap layer, would probably be the best way.

Shadow casters are otherwise fairly simple to use, it does requires a Universal Render Pipeline project. This short video should help, link

edit: This guy seems to be on to something! link 

Will see if i can try this out later

(1 edit)

Ok tried the Tilemaps Shadow Caster in the second link. Could not get it to work with the generated shared walls tilemap layer. Or it actually generated shadow casters but they didn't show up. I did have to do this in play mode, so not sure if that's the problem

It does kind of work if you put it on each of the wall object inside a room template, but the same problem as before occurs when intersecting with corridors. The auto generated shadows are also not perfect.

Is there a reason why the auto-generated shadows are not perfect? I thought that it would just use the polygon tilemap collider and compute the precise shape of the walls. Do you need something more than that?

yeah I was hoping it would do that too. It doesnt seem to be able to handle a merged wall object that well. Not sure though. It looks like this: link

Oh, I see. I might try this myself but it might take at least 1-2 days to get to that.

Thank you, take your time :). 

So I’ve done a fair bit of research and it seems like the main problem is with shadows in enclosed areas (which the dungeon is). You can see a discussion here: https://forum.unity.com/threads/script-for-generating-shadowcaster2ds-for-tilemaps.906767/#post-7220347 . And as far as I know, these people do not have a working solution for this. However, someone from Unity replied there that in Unity 2021.2 it should be possible to access collider shape primitives and that it may be easier to fix these problems. I also tried working on my own solution but it’d require quite a lot of polishing and would also probably become obsolete soon as 2021.2 is already in its beta stage. So I’d probably recommend waiting for the new version of Unity where it should be easier to automatically generate the shadow caster shapes.

Ok, thank you for your research! Will hold off on that front until the new version.