Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | avlakos |
hello.
the issue is, that after pressing dash keybutton my player character starts to dash and never returns to the initial velocity. i can’t understand why it’s happening.
thanks for your help in advance
fragment of code:
func apply_movement():
x_input = Input.get_action_strength("right") - Input.get_action_strength("left")
velocity.x = lerp(speed * x_input, velocity.x, 0.2)
if Input.is_action_just_pressed("dash"):
dash()
velocity = move_and_slide(velocity, Vector2.UP)
func dash():
dash_timer.start()
velocity.x = lerp(dash_speed * x_input, velocity.x, 0.1)
func _on_DashTimer_timeout():
velocity.x = lerp(speed * x_input, velocity.x, 0.2)