Is there a solution to make player increase it's speed when key is pressed?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yozhik

2d top-down game. player controller - move_to_mouse
e.g. we’ve got a var speed
and player moves toward some direction
I want him to “warp” almost instantly for a 100-150 px but not to animate it, I want to see how it’s speed increases for a bit, and then decreases right at the end of a warp.
visual effects I will add by myselft I just need help to understand how to “boost” him.

:bust_in_silhouette: Reply From: Cellist1972

Did you try linear interpolation? https://docs.godotengine.org/en/stable/tutorials/math/interpolation.html

:bust_in_silhouette: Reply From: Yozhik

speed = 100

event press button
speed = 500
yield(get_tree().create_timer(0.25), “timeout”)

speed = 100

smt like that

:bust_in_silhouette: Reply From: toivocat

You can simply do:

var speed = 100

func _process(delta):
    if Input.is_action_just_pressed("increase_speed"):
        speed += 100

I am assuming that you set the speed to 100. You can change it by just changing the value of the variable speed.