How to fit the camera to randomly generated dungeon

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Andrew Maher

I follow a tutorial to generate random dungeon from a tilemap, now after generating, I got the view like this picture.

Game View

Now I want the camera to fit the view so that I can’t see anything except all dungeon,
and I have the size of the full rectangle of it.

You didn’t provide a picture. Also: What exactly is your question here?

njamster | 2020-02-21 14:21

I’m guessing he has a randomly sized level, and wants the camera to adjust its positioning and extents to tightly fit the generated level size, so you can see the whole level but minimal extra space.

I think you’re going to want to use the tilemap’s get_used_rect() and then modify the cameras extents or zoom based on that.

denxi | 2020-02-21 14:51