0 votes

I am trying to implement a top-down 2D game using a TileMap with a Light2D set to Mask mode in order to implement fog of war.

If I build a TileSet Autotile with Occluder2D squares for each tile and position a Light2D on the player, the fog of war effect is achieved but the walls themselves are blacked out. I would like to be able to see the walls but not what is behind them.

My next idea was to set the cull mode to Clockwise so that only the backfaces of the Occluder2D would cast a shadow. This works to some extent, but because there are faces between each tile in a continuous wall section, unwanted shadows are cast from within the wall as described in this post: How can I make tilemap walls with an occluder show and cast shadows?

Finally, I discovered I could describe an unclosed Occluder2D on a tile which was a single face rather than a closed polygon. This works great for one edge of the tile but not the opposite edge. If I was able to add multiple occluders to a single tile I think I could solve the problem, I would use unclosed lines rather than closed polygons to draw the outline of the wall. However, it doesn't seem to be possible to add more than one occluder to a tile even if I create a separate scene and bulid the tileset the old fashioned way.

I tried examining the tileset.tres file and even modified it to associate two occluders with a single tile. When the tres file is next parsed by the editor, one of the occluders is removed.

Any ideas how I can achieve the desired effect? Is it possible to modify the behaviour of TileMaps without needing to delve into the underlying C++ code? Or can anyone think of a better way to solve this problem?

Thanks!

asked May 6, 2019 in Engine by gareththegeek (19 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.