0 votes

i was trying to make my player to dash in a short amount of time. But it dashed once and didnt dash again at all. And there was no issue with my scripting. And i think timer nodes might doesnt work well inside signals. or there is a problem with my scriipting?

And i was trying to troubleshoot, then what i found is that cool_down node doesnt start.

Here is my script:

dash_av = 1

if Input.isactionjustpressed("player1dash") and Input.isactionpressed("uiright"):
dash()
if Input.is
actionjustpressed("player1dash") and Input.isactionpressed("uileft"):
dash()

func dash():
$dashtime.start()
maxspeed = 1500
motion.y += gravity * 2
acc = 2000
dash
av = 0

func ondashtimetimeout():
maxspeed = 500
acc = 100
$dash_cooldown.start()

func ondashcooldowntimeout():
dash_av = 1

in Engine by (14 points)

1 Answer

0 votes

Here is the code I test, it work.

var dash_av = 1

func _ready():
    $dash_time.one_shot = true
    $dash_cooldown.one_shot = true

func _input(event):
    if event is InputEventKey:
        if Input.is_action_pressed("ui_right") and dash_av == 1:
            dash()
        if Input.is_action_pressed("ui_left") and dash_av == 1:
            dash()

func dash():
    print("dash")
    dash_av = 0
    $dash_time.start()

func dash_time_timeout():
    print("dashtime_timeout")
    $dash_cooldown.start()

func dash_cooldown_timeout():
    print("dash_cooldown_timeout")
    dash_av = 1
by (603 points)

TY so much, it worked

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.