If you want to create shaking movements, basically you can make do it by setting set_offset in the process(delta) as mentioned in the Godot FAQ.
But it’s difficult to customize for more tricky movements. We can do it if we want to, but it’s definitely a hassle.
For that reason, I will use Tween instead of that.
Tween is an even more customizable node than AnimationPlayer, so it is useful for expressing random movements in script.
This article explains how to shake randomly a Node object such as Sprite.
First, create Sprite node and add Tween node in it.
Assign the Godot icon to the texture of Sprite.
Next, connect the signal of Tween named tween_completed.
After that, assign the script to the Sprite and write code as follows:
You should see that the sprite is shaking as below.
If you want it to shake faster and stronger, change values of the shake_amount and shake_speed.
var shake_amount = 20.0
Then, Sprite will shake violently.