Is Camera2D.set_offset() performant enough to use in every frame?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cardoso
:warning: Old Version Published before Godot 3 was released.

I am using a Camera2D attached to the root node, even though the camera ultimately moves with the player through code. The reason for this is to have more flexibility.

I have been using Camera2D.set_offset() for that purpose and no problems so far.
But in the docs is written about set_offset(): “Set the scroll offset. Useful for looking around or camera shake animations.”
Which makes me think if it is a good idea to use every frame.

So, is it ok?
If not, what other ways there are?

:bust_in_silhouette: Reply From: Zylann

set_offset() is another way to move the camera relatively from its position, without actually modifying the transform of the Camera node. It should be allright to call it on every frame.

It is intented to be used as a secondary positionning parameter. Screen shake is given as an example because it typically doesn’t changes the camera’s looking target, but has to make it move a bit around it. You could do everything with set_pos(), but using set_offset() can make logic work independently from the transform.

I think this is also useful if you enabled smoothing, because set_offset() won’t be affected by it, unlike set_pos() (didn’t tested yet, thought).

Thanks!
You are correct, set_offset() ignores smoothing.
set_pos() causes some weird screen shakes occasionally. As I will be developping I will try to check if it is my code or a Godot issue.

cardoso | 2016-06-06 14:24