Topic was automatically imported from the old Question2Answer platform.
Asked By
CyttilDalionzo
Old Version
Published before Godot 3 was released.
Hi all,
So I have a scene that contains my tileset, which has some Sprites with a Light2D attached to them. However, when I export the tileset and try to use it, the lights have mysteriously vanished (though the rest works fine).
Is it simply not possible to include lights in a tileset like this? Or am I doing something wrong/forgetting something? (If it isn’t possible, how else could I get the proper lights with their corresponding tiles?)
You have to add the lights afterwards, with something like this:
var cell_positions = tilemap.get_used_cells()
for pos in cell_positions:
var tile_id = tilemap.get_cellv(pos)
var tile_name = tilemap.get_tileset().tile_get_name(tile_id)
if tile_name == "my_light_tile":
# Create your light here...
Yeah, because tiles also contained Occluder information, I thought they must also contain Light information, but I guess I was wrong. Thanks, your provided code works!
CyttilDalionzo | 2016-09-26 07:56
It can be improved btw, I just wrote it as an example
Zylann | 2016-09-26 12:36
Yeah, I ended up just checking the number of the tile that was being placed, and instantiating a new light if that number corresponded with a light-tile (because I have the numbers hard-coded). Works fast and smoothly.