Set the node in place of the tile

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

Hi. How to put a node instead of a tile on a tilemap. A certain node on a certain tile. To do all this through the script function _ready

:bust_in_silhouette: Reply From: purple_mage
@onready var yournode = preload("res://node.tscn")

var b = yourNode.instantiate()
tile.add_child(b) 
b.position # if its not on top. you just change y axis i think

if you want to do something after you can group them in a group and do something like get_nodes_in_group is in group ect. Hope that a good awnser :stuck_out_tongue:

Hi. I want to add. I have a lot of different tiles. I need to set a certain tile to a certain node. How to get tile coordinates and their custom data

Dillon | 2023-03-27 20:41

@export var variable_data: NAMEOFTHEVARIABLE

then you can set them in the viewport under inspector when you click on the object that has the script

the coordinate is equal to tile.position i think !

purple_mage | 2023-03-28 22:32

If you want acces to the value you do something like theinstanciatedobject.value !

    extends Resource

class_name ItemData

@export var name: String = ""
@export_multiline var description: String = ""
@export var stackable: bool = false
@export var texture: Texture #Texture

purple_mage | 2023-03-28 22:34