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

in Engine by (840 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)

by (28,882 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 Frequently asked questions and 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 [email protected] with your username.