Randomize the initial direction of the headbob animation

This commit is contained in:
2024-01-20 18:05:15 -08:00
parent db61d9b4cd
commit 18a862cb9a

View File

@ -228,8 +228,14 @@ func update_camera_fov():
func headbob_animation(moving): func headbob_animation(moving):
if moving and is_on_floor(): if moving and is_on_floor():
var was_playing : bool = false
if HEADBOB_ANIMATION.current_animation == "headbob":
was_playing = true
HEADBOB_ANIMATION.play("headbob", 0.25) HEADBOB_ANIMATION.play("headbob", 0.25)
HEADBOB_ANIMATION.speed_scale = (current_speed / base_speed) * 1.75 HEADBOB_ANIMATION.speed_scale = (current_speed / base_speed) * 1.75
if !was_playing:
HEADBOB_ANIMATION.seek(float(randi() % 2)) # Randomize the initial headbob direction
else: else:
HEADBOB_ANIMATION.play("RESET", 0.25) HEADBOB_ANIMATION.play("RESET", 0.25)
HEADBOB_ANIMATION.speed_scale = 1 HEADBOB_ANIMATION.speed_scale = 1