-
-
Save WolfgangSenff/007d2587da00abf3f2df523636eebd92 to your computer and use it in GitHub Desktop.
A horizontal shake method to help add hit stops to your games!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node | |
# Make this a global singleton if you want | |
func shake_horizontal(thing, strength: float) -> void: | |
var orig_pos = thing.position | |
var current_amount = 6 | |
var shake_count = int(abs(current_amount)) | |
for i in shake_count: # Tweak these values | |
var tween = create_tween().tween_property(thing, "position", Vector2.RIGHT * pow(-1, i) * strength * current_amount, 0.01) | |
await tween.finished | |
current_amount *= .75 | |
thing.position = Vector2.ZERO | |
# Will add all-ways shaking in the future, after I've implemented it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is for Godot 4.0.