Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | TheWomboKombo |
As the title states, I am trying to instance a scene (pickup) on every one of the specified tiles (pink). Here is my code so far:
onready var pickup_scene = preload("res://Pickup.tscn")
func spawn_pickup(tile_position: Vector2):
var instance = pickup_scene.instance()
instance.position = tile_position
add_child(instance)
func generate_pickup() -> void:
for tile_position in get_used_cells():
if get_cellv(tile_position) == tile_set.find_tile_by_name("pink"):
spawn_pickup(tile_position)
this code is located at the very bottom of my tilemap’s script. I also have an enum with my tilemap name’s and id’s at the top which is where my pink tile is named.
When I run this code I get no error, but I also have no pickups spawning on my pink tiles. What am I doing wrong?
Thanks in advance.
Just to make sure, you are calling generate_ pickup() at some point?
get_ used _cells _by _ id() might be faster, where you dont have to pull up the entire tile map, although it probably it does.
MattMakingAGame | 2021-10-20 06:52