Invisible tiles with collision

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

How does one place tiles that are invisible or run-time? I plan to have it visible whilst editing the project, but upon running, it becomes invisible, but its collision still works. It works somehow like the barrier block in Minecraft. Its the closest example I can think of.

The tile I’m planning to make invisible is the red void tile highlighted. Its there on the 2nd floor to prevent manually controlled entities from walking of the edge of the raised platform.

:bust_in_silhouette: Reply From: eons

You can add a script to the tilemap:

func _ready():
  tile_set.tile_set_region(invisible_tile_id, a_transparent_region)

Should be possible with modulate too but looks like is not exposed to gdscript, not on 3.0 at least but may be accesible via set.

I made it a different way, I separated the void tiles into a different tilemap, had them hidden and their collisions still appear. I usually end up solving majority of my own problems with hints from others or similar instances I find online.

rabbitslime | 2018-08-10 04:31

:bust_in_silhouette: Reply From: WiperR

If someone is still scrambling his/her brain in this I came up with solution.

extends TileMap

const BARRIER_ID := 22

func _ready() -> void:
    for cell in get_used_cells_by_id(BARRIER_ID):
	    set_cell(cell[0], cell[1], INVISIBLE_BARRIER_ID)