-
Notifications
You must be signed in to change notification settings - Fork 390
-
@Stregoica777 is imagining a forest maze for a forthcoming quest, and I have been wondering about ways to add randomness to Threadbare to add a bit of spice/seasoning to our menu of challenges. Inspired by a talk by Jackie Codes at GodotFest 2025 I thought I would try making a forest using a TileMapLayer whose TileSet contains scenes that are composeable blocks of forest.
Here's a simple scene. It's ×ばつ64 tiles in size, with the origin in the centre. It has a 2-tile-wide path at the north, east, south and west face. The forests are a StaticBody2D using an AreaFiller.
imageThe idea is that we would make a few more of these, some of which only have exits on 2 or 3 edges; and then put them together to make a maze.
Here's a scene that contains a TileMapLayer whose TileSet has one scene collection source containing just this one scene. I placed ×ばつ3 copies of the scene in it.
imageInitially I thought it seemed quite promising but then I looked at the joins. The y-sorting doesn't work correctly:
imageThe scene tree for a simplified version with just 2 scene-tiles looks like this:
imageYou might hope to just tick "Y Sort Enabled" on lots of things but no: you don't want the TileMapLayers in the child scenes to be y-sorted, only the trees.
I tried a little script that hoists nodes from the tile-scenes' OnTheGround node to the host scene's OnTheGround node, and this does work:
# SPDX-FileCopyrightText: The Threadbare Authors # SPDX-License-Identifier: MPL-2.0 extends Node @onready var tile_map_layer: TileMapLayer = $"../TileMapLayer" @onready var on_the_ground: Node2D = $"../OnTheGround" func _ready() -> void: # Child scenes are only added at the end of the current frame. Force an update now. tile_map_layer.update_internals() # "Promote" all on-the-ground entities (which should be y-sorted) out from each # tile-scene to the host scene. for tile: Node2D in tile_map_layer.get_children(): var sub_ground := tile.get_node(^"OnTheGround") for child: Node2D in sub_ground.get_children(): var p := child.global_position sub_ground.remove_child(child) on_the_ground.add_child(child) child.global_position = p tile.remove_child(sub_ground)
The other thing I wanted to explore was whether you can rotate a scene-tile when placing it, and the answer is no:
imageThis kind of makes sense because I wouldn't actually want to have the trees rotated 90°, and our tiles aren't rotationally symmetric, but still I was a bit disappointed because it would have meant that designing 1 tile would in fact give 16 options (4 rotations ×ばつ horizontal flip ×ばつ vertical flip).
Beta Was this translation helpful? Give feedback.