Changing the tileset after an event was triggered ?

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

Hello Godot’s community !

I’m working on a 2D project called Fragments, where the player takes the shape of a wisp that has to collect light fragments in a decaying world in order to bring back life to said world.

I was wondering if it was possible to replace a base tileset (ex : dead ground with no grass, flower ect) with another one (ex : grass and flowers growing ) after an event was triggered (in that case, when the player completes the level) ?

I’m still very new to Godot and this is my very first little project I’m doing by myself, without any tutorial.

I hope this makes sense, English isn’t my first language.

:bust_in_silhouette: Reply From: njamster

Sure. You can either switch out the entire TileSet:

tile_set = load("res://<PathToYourTileSet>.tres")

or change the tile used in some cell (x, y) of your TileMap:

set_cellv(x, y, <TileID>)

A TileID of 0 will clear a cell. To get the current value use get_cellv(x, y).

I see, that’s pretty simple then ! Thank you for your quick answer ! :slight_smile:

Lothrinn | 2020-05-04 14:03