Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ArthurER |
I am working on a top down 2d RTS project and am wondering how to go about making so the view of the play area is greyed/blacked out until a player unit travels across it. I imagine a patern of area 2d set to hide after player collision would work but don’t know how to implement that so it can generate itself
this is the part of the map script that I think I could use to generate that, it is part of the level script to set camera limits and centre camera start position on the map
func _ready():
screen_size = get_viewport_rect().size
var map_limits = map.get_used_rect()
var map_cell_size = map.cell_size
$Camera2D.position.x = (map_limits.end.x * map_cell_size.x) / 2
$Camera2D.position.y = (map_limits.end.y * map_cell_size.y) / 2
$Camera2D.limit_left = map_limits.position.x * map_cell_size.x
$Camera2D.limit_right = map_limits.end.x * map_cell_size.x
$Camera2D.limit_top = map_limits.position.y * map_cell_size.y
$Camera2D.limit_bottom = map_limits.end.y * map_cell_size.y