Godot Version
4.3
Question
` I am currently creating a mini-map interface for my game using a Grid Container node. I have set up a Table to represent the map. I decided not to use the TileLayer node because I want the mini-map to stretch and expand dynamically, as the map will change in size depending on the game situation. I felt that the Tile Map node wouldn’t work for this purpose.
If I am making this more complicated than necessary, please let me know.
Here is the code I have created so far. `
extends GridContainer
const PLAYERPANEL = "P"
const WALL = "W"
const FLOOR = "F"
const DOOR = "D"
var DoorScene = preload("res://door_panel.tscn")
var WallScene = preload("res://wall_panel.tscn")
var FloorScene = preload("res://floor_panel.tscn")
var PlayerPanelScene = preload("res://player_panel.tscn")
var map_data = [
["W", "W", "W", "W", "W", "W", "W", "W", "W", "W"],
["W", "F", "P", "F", "F", "F", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "F", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "F", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "F", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "F", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "F", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "D", "F", "F", "F", "W"],
["W", "F", "F", "F", "F", "F", "F", "F", "F", "W"],
["W", "W", "W", "W", "W", "W", "W", "W", "W", "W"],
]
func _ready():
self.columns = map_data[0].size()
for row in map_data:
for cell in row:
match cell:
PLAYERPANEL:
add_player_panel()
WALL:
add_wall_panel()
FLOOR:
add_floor_panel()
DOOR:
add_door()
func add_player_panel():
var player_panel = PlayerPanelScene.instantiate()
add_child(player_panel)
func add_wall_panel():
var wall_panel = WallScene.instantiate()
add_child(wall_panel)
func add_floor_panel():
var floor_panel = FloorScene.instantiate()
add_child(floor_panel)
func add_door():
var door_panel = DoorScene.instantiate()
add_child(door_panel)
My issue is that when the Player loads into the Scene, it does not appear on top of the player panel. After experimenting with the code, I’ve noticed that this problem occurs because the player node is a 2D Node rather than a Control Node.
When isolated in its own scene, the Player loads as expected on top of the player panel. However, when loading into the Main Screen, it either does not load inside the Container or loads incorrectly. Please refer to the attached images for clarification.