I used to have similar code that worked perfectly fine, but at some point it stopped working.
Basically, vault_strength
is getting immediately moved toward 0
even if vault_boost_decay
is set to an extremely small number.
I have Git, but I had so many random unnamed commits that I have no clue which caused the bug.
How do I slow the decay?
func ascend(delta:float):
#Update boost after vault
vault_strength = move_toward(vault_strength, 0, vault_boost_decay * delta)
vault_vel = dir * vault_strength
#Detection
if Input.is_action_just_pressed("jump"):
jump_buff = get_tree().create_timer(ascend_buff_time)
#Jump or vault
if jump_buff.time_left > 0:
#Vaulting
if vault_cast.is_colliding():
if Vector3.UP.dot(vault_cast.get_collision_normal(0)) > 0:
#Update timers
jump_buff = get_tree().create_timer(0)
jump_debounce = get_tree().create_timer(ascend_cool)
#Local vars
var vault_diff := vault_cast.get_collision_point(0) - global_position
var height:float = vault_power + vault_diff.y * vault_power_growth
#Apply impulses
base_vel.y = height
base_vel.x *= vault_speed_multi
base_vel.z *= vault_speed_multi
#Stacking?
if vault_boost_stack:
vault_strength += vault_boost
else:
vault_strength = vault_boost
#Play animation
anim_plr.play("Vault")
#Handle collisions
if dir.dot(Vector3(vault_diff.x, 0 , vault_diff.z).normalized()) > 0:
collision.disabled = true
await get_tree().create_timer(vault_clip_time).timeout
collision.disabled = false
#Return to prevent jump
return