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.