From 18a862cb9a22b6df48956bb16b95b111f3a39312 Mon Sep 17 00:00:00 2001 From: Zakarya Date: Sat, 20 Jan 2024 18:05:15 -0800 Subject: [PATCH] Randomize the initial direction of the headbob animation --- addons/fpc/character.gd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/fpc/character.gd b/addons/fpc/character.gd index 14b96fb..0449104 100644 --- a/addons/fpc/character.gd +++ b/addons/fpc/character.gd @@ -228,8 +228,14 @@ func update_camera_fov(): func headbob_animation(moving): 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.speed_scale = (current_speed / base_speed) * 1.75 + if !was_playing: + HEADBOB_ANIMATION.seek(float(randi() % 2)) # Randomize the initial headbob direction + else: HEADBOB_ANIMATION.play("RESET", 0.25) HEADBOB_ANIMATION.speed_scale = 1