How to 'hide' (i.e. darken) a group of cells in a tilemap?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By _bjork

Is it possible to hide or make some cells invisible in one Tilemap? Similar to Project Zomboid when you are indoors, you can only see those tiles inside the room, and not those of the room behind the wall for instance.

In this example the door is open and so are the windows allowing you to see outside the room and house

In here however, since there is no open door or window, everything else but the room is dark.

I am looking forward to implement something similar to the second picture, having those tiles that compose a room, how would I end up doing this in Godot? Is there any gamedev magic i’m missing?

:bust_in_silhouette: Reply From: Merlin1846

I’ve played that game and know what you’re talking about, and here’s what I would do. I would create a second tilemap that is rendered after the main tilemap and this second tilemap would have a single all-black tile that goes over any tile you want to darken. Another way to do this would be to use the shadow occlusion system for tiles. You could also set the light2d to reveal things rather than cast shadows, although this is more complicated it means that everything outside of the light is completely black. Also, I’m assuming you’re working in 2d and don’t have a custom tile system. And another way to do this would be using shaders but I don’t know much about them.

EDIT: I believe that project zomboid simply doesn’t render those tiles which would make the whole system more complicated if you want to do it exactly as they did.

Thanks for the proposal, while I do have my data tile system (my game has its own building system integrated in it), I do use tilemaps to reflect the data to the visual port. I will implement the first proposal and see how it goes.

_bjork | 2021-11-22 13:28