Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | dgGrifo |
I am trying to create a super simple MiniMap for my game, where the only info it shows is a marker for the player on the center of it and white rectangles representing the boundaries of the map. The game is a top-down 2d, and currently I have a TileMap inside my world scene that ONLY contains the tiles that shall be used as boundaries, and a MiniMap scripted scene.
Right now I could only instantiate the TileMap (using an export var), but I could not place it inside the actual minimap. My current code for the minimap.gd:
extends MarginContainer
export (NodePath) var player # player
export (NodePath) var bounds # bounds TileMap
export var zoom = 1.5
onready var grid = $MarginContainer/Grid
onready var playerMarker = $MarginContainer/Grid/PlayerMarker
var grid_scale
func on_ready():
# setting marker's position to be centered
playerMarker.position = grid.rect_size / 2
# scaling grid based on zoom
grid_scale = grid.rect_size / (get_viewport_rect().size * zoom)
# placing tilemap
place_tile_map()
func place_tile_map():
# where the TileMap should be created inside the grid, but I couldn't figure out how
I would also need to show the tiles in a stylized way, so the MiniMap would be a black and white UI for the player, and the actual map would be normally shown.