To create a dash we will use Timers and duplicate a node

We will split dashing into two functions - the dash and the effect

In the Player Scene add three new timers as children of the CharacterBody2D node

Name them DashDurationTimer and DashEffectTimer and DashCoolDownTimer

Set  wait time for DashDurationTime to 0.4

Set  timer to One Shot

Set wait time for DashEffectTimer to 0.1

Set  wait time for DashCoolDownTimer to 2

Set the timer to One Shot

In the Player Script add three new global variables:

is_dashing, can_dash and dash_speed

We also need access to the timers

add reference variables for both of them.

Dash function

We need a custom action event linked to a key for dashing.

To create this:

Add a new Input Action for the dash Click on:

Project --> Project Settings --> Input Map

Where it says: Add New Action, type in dash

 Then press Enter

Click on the + and the system will wait for an input to register with the action word dash.

Press a key to associate with dash - I have used E

Code the dash function:

If the player presses the dash key and dash is not in cool down

set is_dashing to true

put dash in cool down

start the dash timer

start the dash effect timer.

start the dash cool down timer.

If dashing increase speed by dash speed

Do not dash upwards

Call the dash function in process

Connect the timeout signal of the DashDurationTimer and code it:

Connect the timeout signal of the

DashCoolDownTimer and code it:

The Cool Down Timer prevents the player from being able to spam the dash key and essentially fly.

The player can now dash!