+2 votes

I just want a real time minimap in one part of screen where the user can see a larger part of world around main user. In other worlds, a second zoomed out camera in a smaller viewport.

in Engine by (51 points)

1 Answer

+2 votes

I did a search for "minimap", and I see other users asked the same question: https://godotengine.org/qa/search?q=Minimap

by (27,896 points)

Yup checked all those but those answers recommend static unchanging sprite as map. How do I get it in real-time i.e, which changes when my main player(Rigidbody2D+Camera2D) moves around?
So far a few answers did mention having multiple cameras or viewports but did not mention how to do it. Is there a way to get a viewport inside another viewport with same camera at different zoom levels?

There is basically two ways:

1) Have a background, static or generated once, and draw dots or minisprites on top of it. It is cheaper because you don't need to draw the whole world twice, but needs a bit more code.

2) Using a secondary viewport that renders the world zoomed out. That one is easier but can be performance-hungry depending on how many things your world contains. Also, it might not look exactly like you expect, for example you usually want to see clearly on the minimap, but because it's just a zoomed-out viewport you'll see a tiny pixel mash of the real world, not always good to distinguish objects.

You can take these two approaches and try what is best for you, because there is no "best" solution and it depends a lot on what you want to do exactly, not all minimaps are the same.

For a minimap that really renders the world a second time, you actually need two viewports:
One that renders the world, and ONLY the world (not the GUI),
One that renders the same world but on a smaller rectangle (the minimap).
The first viewport will have your game world as a child, with one camera for the player and another one for the minimap.
For the complete setup you can have a look at the the split-screen example, that you can find here: https://github.com/godotengine/godot-demo-projects/tree/master/2d/split_screen_platformer
Why split-screen? Well, your minimap is like a second screen then^^
Take your time to understand (I'm discovering it too btw), it requires a bit of scripting and tinkering with the options, but if you really want to draw the world twice, that's what you are looking for.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.