Camerashake doesn't return to it's normal position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By brikica

I followed this tutorial (, it was the only screenshake I could manage to make work, the nodes look like this:

SimpleNode (Screenshake) - it has the script
        Tween(For smoothing the shake)

The screenshake script is this:

The camera just has a simple position.y -=1
So whenever I call the shake, it works, but it f’s up the camera, I’m guessing thats because of the 4th arg in the Tween.interpolate_method()which is set to Vector2(0, 0) and afaik that is where the camera is supposed to reset to after the shake. However since the camera moves it doesn’t work. (At least I think that’s what’s happening I’m still kind of a noob lol)

I would say the solution would be to somehow store the camera position right before the shake and just reset to that. I played around for a few days and I can’t figure it out, idk if that’s even the right way of solving the problem.

Any help is greatly appreciated :slight_smile:

From what I can tell, the shaking has to be programmed such that, even though the shaking looks random, the shaking animation needs to end at where it started. In the screen_shake() function, when the “shake” is about to end, the camera should be moved (or tweened, can’t tell) into its original spot.

Ertain | 2019-10-06 16:34

That’s what I thought aswell, however I don’t know how to achieve that, and I don’t even know how to google that, my programming google-fu is serously lacking lol

brikica | 2019-10-06 18:02

Maybe you could detect when the shake ends? At that point, check to see whether the camera has returned to its original position (save the original offset to some variable, orig_offset, before doing the shake). If it’s not in the original spot, either assign the original offset to the camera (e.g. get_parent().get_node("camera").set_offset(orig_offset)), or use tweening when the original has ended (could even use a Tween signal for that).

Ertain | 2019-10-06 19:17

:bust_in_silhouette: Reply From: Matheus Pesegoginski

Your tween is not doing anything, you should add the parameter from the function in the camera offset, like that:
get_parent().get_node("camera").offset = vector

It doesn’t solve the problem, but it is something I forgot to do. :slight_smile:

brikica | 2019-10-06 18:01

:bust_in_silhouette: Reply From: scrubswithnosleeves

Here is a tutorial I made on this.

I go over how to make the camera return to the center at 2:11