Hi,
I have a 2D tilemap with a player character. The player character has a camera attached which follows his movement.
I want to display a map node above the player sprite when the hotkey is pressed (centered in the camera).
The problem is I can't calculate the correct centered position inside the camera.
When I try to center it by using visible rect of camera viewport, I get some fixed position that doesn't change once the player has moved. Here's the code:
map_pos.x = get_node("Camera2D").get_viewport().get_visible_rect().size.x - map.get_node("Panel").get_size().x
map_pos.y = get_node("Camera2D").get_viewport().get_visible_rect().size.y - map.get_node("Panel").get_size().y
How can I calculate the center coordinates of the camera viewport, and put something in them?
Thanks.