Views and cameras (Godot 3)

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

Hi my dear brothers and sisters in code!

I apologize to all grammar nazis for my horrible english… I learned from famiclone games and fansubs

Well. Last 12 years i was working with game maker. And… Old habits die hard. So, i solved most of things by myself… Until now! My problem is : i am incredibly dumb… And my godot problem is : how to use views and cameras.

He is really dumb.
His mom.

In gamemaker, i just opened room (scene) and in settings i configured view. Even if i activated view, rectangle representing view was shown in room.

But in godot? Created Node, then viewport as a child and then camera2d as a child of viewport. My question is… What next?

He is too dumb.
Said his dad before he left.

And what i am trying to do?

Well. I changed display size to 1280x720. Now i want to somehow set view to 320x180 and then stretch it to 1280x720 (for retro look). And then i want set up camera to follow player. I tried to search godot database but i did not found any information how viewports and cameras works.

He is dumber than most of people here…
His dead uncle

So, please assume i am 5 years old dumb kid and you trying to explain that to me. If you want, you can use pictures. One picture is worth thousand words.

:bust_in_silhouette: Reply From: Zylann

Chances are, you don’t need a Viewport node for that. Godot games have a Viewport already, and it’s the window itself. This is not something you setup per scene, it is global to the game. You can use sub-viewports, but the use case you describe most likely doesn’t need that.

If you want to give a pixel-art retro look to your game, what you can do is indeed to open Settings and give your game low resolution. You can also configure the stretch mode to 2d, and keep aspect ratio. With those options, you will get a very small window, but if you resize it / maximize it, you will get retro look.

Another way is to use camera zoom. By default, Godot allows you to make a game without camera, but you can also define yours by creating a Camera node and set it as current (this is also very useful for scrolling). It shows another rectangle to preview the area it will see. Then, you can modify its zoom property to see closer to the pixels. If you go with this solution, then you won’t have to reduce the resolution of the window, since the camera will do the zoomed pixels effect :wink:

Thank you very much Mr Lego Zylann!

Druid | 2018-01-30 19:03