How do i add a tiles to the scene while its being played?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By J u s t N a t e

Im making a game that will have growing vines. i want to be able to use a tile set for the vine but i dont know how to add a tile when the scene is being played. Im going for something like minecrafts vines but in 2d.

Any suggestions?

Suggestions for what?

njamster | 2020-08-04 13:06

I’m not sure what you are going for exactly but, if I’m understanding this right. You want a vine that can grow and shrink. Possible bridges and pathways kind of mechanic right? I think it would be best to have an animated sprite and two collisionshapes attached to it. One collision shape for when the vine is short( Blocks player) and the other collisionshape that allows the player to move on. You can toggle between the two collisionshapes with $collisionshape__name.disabled = true or false. or you can animate the one collision shape with the animationplayer. Totally up to you and what better suits your needs. Hope that helps :slight_smile: If not please elaborate more so others can better understand and help you. farewell!

RakuNana | 2020-08-04 19:19

Thanks for the suggestion, but i want to be able to use a tile set for the vines. i just want to know how to add a tile to the scene in the script. if that makes sense?

J u s t N a t e | 2020-08-04 22:08

:bust_in_silhouette: Reply From: njamster

i just want to know how to add a tile to the scene

get_node("TileMap").set_cellv(Vector2(1, 2), 0)

This will set the second cell from the left and the third cell from the top to the tile with the id 0, assuming you already added a TileSet with at least one tile.