#Get tilemap from another scene to use in code

3 messages · Page 1 of 1 (latest)

mortal grotto
#

really begginer question here, but i cant seem to figure it out. the code is this: i've tried it a bunch of different ways, and i cant seem to get it to work.

extends CharacterBody2D
@export var map : PackedScene

func _ready():
var TileMap = %MapInstance.get_child(1)

and the error is: Cannot call method 'get_child' on a null value.

wraith sinew
#

Make sure to use a non-existing variable name.
Doing var tilemap, var tile_map or var my_tilemap will work

but var TileMap will not, because when you do TileMap it will get the already-existing TileMap class built into Godot, not your variable