![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | brikica |
I followed this tutorial (https://www.youtube.com/watch?v=wQGVOw_CPNs), 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
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