Instancing tilemap in godot.

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

I am trying to create a platform game like temple run in 2D. I created the platform using tilemap . But how can I instance the tilemap as the player moves ?

:bust_in_silhouette: Reply From: Merlin1846

You have to instance it like any other scene.

var tileMap = preload("PATH TO SCENE")

func placeTileMap(pos,rot):
    var tileMapInstance = tileMap.instance()
    tileMapInstance.position = pos
    tileMapInstance.rotation = rot
    $"TILE MAP MANAGER".add_child(tileMapInstance)

Thanks for your code.
I create a spawner_ground(Node2D) and attached a child node TILE MAP MANAGER(Node).Put the code in spawner_ground script . But on executing i got a blank screen . Why is that ?

Yasin | 2020-03-27 16:28