Godot Version
Godot v4.3
Question
Hey guys. This is my first question in the forums.
So here is what I am trying to do.
I have a Tilemap in my main scene with tiles from a scene source tileset. Each tile corresponds to another scene. Let’s call it couch.tscn.
The couch scene has a TileMapLayer itself and a MeshInstance3D. The TileMapLayer contains a drawing of a couch and the MeshInstance3D contains a model of a couch. What I want to do is use the tilmap to design my level which is 3d but works on a 2D grid. So I want to place the couch model at a position on the stage that corresponds to the cell position of the tile representing the couch.
Here is the problem. One problem is that scene sources don’t seem to support rotation so I have no way to know to rotate my couch model other than create alternatives. The biggest problem is that when I run my game I keep seeing in my 3D camera the couch model on the same position, I can’t seem to be able to move it. I get no errors or nothing.
This is what I am doing in the TileMapLayer script in my main scene (I am very new to Godot, sorry if I missed things):
extends TileMapLayer
func _ready() -> void:
for cell in get_used_cells():
var tile_data = get_cell_tile_data(cell)
var source_id = get_cell_source_id(cell)
if source_id > -1:
var scene_source = tile_set.get_source(source_id)
if scene_source is TileSetScenesCollectionSource:
var alt_id = get_cell_alternative_tile(cell)
var packaged_scene = scene_source.get_scene_tile_scene(alt_id)
var scene = packaged_scene.instantiate()
for child in scene.get_children():
if child is MeshInstance3D:
child.translate(Vector3(cell.x, cell.y, 0))