What does Camera2D zoom actually do behind the scenes?

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


So I started coding a custom camera in GDScript by modifying the viewport, since Camera2D seems to not work well with ParallaxLayers and zooming.

So, how is zooming actually accomplished behind the scenes?

Greetings, Footurist

:bust_in_silhouette: Reply From: Zylann

Camera position, rotation and zooming are accomplished by scaling the canvas transform on the Viewport: Viewport — Godot Engine (3.0) documentation in English

However, I believe doing this manually will not solveParallaxLayer issues. Something about zoom has been reported already: Camera zoom acts weirdly with Parallax Background, whether "Ignore Camera Zoom" is set ornot · Issue #11555 · godotengine/godot · GitHub

So you may eventually roll your own parallax system (which I did in 2.1 heheh)


thanks alot!

You got any example code how you wrote it?

Greetings, Footurist

Footurist | 2018-02-02 03:08

FYI: I got it to work now by making a CanvasLayer’s children following the “actor”, not the viewport. Only thing that I struggle with is how to implement dragging and smoothing when using this approach…any idea?

Greetings, Footurist

Footurist | 2018-02-02 09:46