Backdash Like Castlevania

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Alex Night
:warning: Old Version Published before Godot 3 was released.

Hello guys!

im tryng to make a dash function:

func backdash():
	var can_dash = true
	var dash_time = 0
	if Input.is_action_pressed("BackDash"):
		if on_ground == true:
			dash_time += 1
		if direction == 1 and can_dash == true:
			if on_ground == true:
				can_dash = false
				velocity.x += -20
		if direction == 0:
			if on_ground == true:
				velocity.x += 20

the problem is:

the backdash last as long as been pressing the button…

i want to make it so it last only a few seconds, like castlevania games

sorry for my english!

:

Edited to fix the code block.

eons | 2018-01-20 17:55

:bust_in_silhouette: Reply From: gonzo191

I believe what you’re looking for is Input.is_action_just_pressed() instead of Input.is_action_pressed(). That is, assuming you’re using v3.0 RC1.

if Input.is_action_just_pressed("BackDash"):
 # process backdash...

im using 2.1

but i´m gonna keep it in mind when i use version 3.0!

thanks for your help! :slight_smile:

Alex Night | 2018-01-21 01:41

:bust_in_silhouette: Reply From: eons

Add a cooldown Timer to enable a variable that allows dashing, and start the timer when blocking the dash, I say a timer and not check dash animation because you may want to prevent instant continuous dash, but using an animation track to toggle a variable is fine too

i forgot about the timers nodes!
thanks im gonna try this! :slight_smile:

Alex Night | 2018-01-21 01:42