0 votes


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

asked Feb 1, 2018 in Engine by Footurist (832 points)

1 Answer

+1 vote

Camera position, rotation and zooming are accomplished by scaling the canvas transform on the Viewport: http://docs.godotengine.org/en/3.0/classes/class_viewport.html?highlight=canvas_transform

However, I believe doing this manually will not solveParallaxLayer issues. Something about zoom has been reported already: https://github.com/godotengine/godot/issues/11555

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

answered Feb 1, 2018 by Zylann (26,787 points)


thanks alot!

You got any example code how you wrote it?

Greetings, Footurist

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

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.