Instancing a tilemap scene 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 ?
I used the code

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)

I create a spawnerground(Node2D) and attached a child node TILE MAP MANAGER(Node).Put the code in spawnerground script . But on executing i got a blank screen. Is. there any other way for instancing a tilemap scene ?

:bust_in_silhouette: Reply From: Zylann

Your code looks correct, assuming your node paths are correct. You think it’s a blank screen, but it’s possible the tilemap tiles ended up showing further away outside the screen? Check the position of the nodes you are instancing, and their parents. Also if you do this with a tilemap, check where the tiles actually are relative to the origin of this tilemap, all these offsets add up.