+1 vote

Hi everyone! i'm brand new to Godot, coming from a very intensive and exclusive Blender 3D background. Godot first attracted me because of it's native 2D game engine, but i've run into a problem!

Since the "camera" or the view area for the 2D game isn't an object, i have no idea how to manipulate it in the game! Specifically, i'm looking to do rotation, but just understanding how to manipulate the camera in the 2D game engine is my goal.
'

in Engine by (71 points)

2 Answers

+6 votes
Best answer

I will describe a typical situation, with camera "attached" to the player.
Assuming you have a simple scene with a child node that is your character.
In the editor:
a) create a Camera2D node as a child of the character.
b) on the camera properties select "Current". That is it!
c) customize. For example, in the "Limit" properties a left with value 0 means that the camera will stop moving left when the character has position 0 or below relative to the root node of the scene (I think).
In "Drag Margin" properties a right value of 0.2, for example, causes the camera to only start moving to the right if the center of the camera is 20% to the right of the player center.

To rotate the camera I suppose you would select Rotating in the editor + in the code use rotate() or set_rot(). I have never tried them.
Assuming you have in the root node a character node named "character" with a child camera named "Camera2D":

get_node("character/Camera2D").set_rot(2)

You can also set the rotation in the editor, but I am guessing you want dynamically in the code.

Hope I helped.

by (386 points)
selected by

woo hoo! thank you both very much!

+1 vote

You can create a Camera node and set it as current in the inspector. Then you can move and rotate it just like any other Node2D.

by (29,090 points)
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.