MENU

Fun & Interesting

Automatically zoom camera to a Tilemap in Godot 4.2

Cashew OldDew 9,046 lượt xem 1 year ago
Video Not Working? Fix It Now

This video aims to solve the issue of setting up a scrollable camera which scales automatically to a given Tilemap. You will learn about the zoom function of the camera and also about camera limits.

With this, you no longer have to think about the camera or to struggle to zoom it to your play area. Just draw your Tilemap and the camera will zoom to fit the smallest side, similar to how it happens in games like Brotato and Kingdom: New Lands. This applies for both vertical and horizontal screens, so it could also be a useful feature for a moving camera in a phone video game.

A more detailed overview for the inverse exponential lerp function can be found in this wonderful blog https://www.gamedeveloper.com/programming/improved-lerp-smoothing- by Scott Lembcke

The tileset assets are from schwarnhild: https://schwarnhild.itch.io/basic-tileset-and-asset-pack-32x32-pixels
Thanks a lot for the time and effort you put into making those!

The tileset used in the animations are from Pixel Frog: https://pixelfrog-assets.itch.io/kings-and-pigs

Chapters:
0:00 How do we want our zoom and camera scrolling to work?
2:17 Scaling camera to the tilemap
15:44 Moving the camera on the tilemap
25:17 Creating limits for the camera
33:51 Final result and capabilities

--------------------
Github repository for this project:
https://github.com/cashew-olddew/godot-tutorials/tree/main/4.2/2%20-%20auto-scaled%20scrollable%20camera

Support me on Ko-Fi: https://ko-fi.com/cashewolddew
--------------------

#gamedev #godot #camera

Comment