ld56/camera_2d.gd

16 lines
414 B
GDScript3
Raw Normal View History

2024-10-06 17:38:16 +00:00
extends Camera2D
@export var randomStrength = 30.0
var shake_strenght = 0.0
var shake_fade = 5.0
func apply_shake():
shake_strenght = randomStrength
func _process(delta):
if shake_strenght > 0:
shake_strenght = lerpf(shake_strenght, 0, shake_fade * delta)
offset=randomOffset()
func randomOffset():
return Vector2(randf_range(-shake_strenght, shake_strenght),randf_range(-shake_strenght, shake_strenght))