0 votes

on line 28 of this script, i added a timeout() signal from a timer node, but it says that this is an "error parsing expression: misplaced func". i'm not sure why this is happening, however. can someone help? script:

extends KinematicBody2D

var UP = Vector2(0,-1)
var dashes = 1
var motion = Vector2()
var right = true

func _physics_process(delta):
    motion.y += 20

    if Input.is_action_pressed("ui_right"):
        motion.x = 200
        right = true
    if Input.is_action_pressed("ui_left"):
        motion.x = -200
        right = false
    if Input.is_action_just_pressed("ui_dash"):
        if dashes == 1:
            dashes = 0
            motion.y = 0
            $Dash.start()

            if right == true:
                motion.x = 600
            else:
                motion.x = -600

            func _on_Dash_timeout():
                motion.x = 0
                pass 

    if is_on_floor():
        dashes = 1
        motion.y = 0
    motion = move_and_slide(motion,UP)
in Engine by (12 points)
edited by

Edited to fix code formatting. Please use the "Code Sample" button when pasting code so that it is formatted correctly.

1 Answer

0 votes

Your indentation is wrong. Functions can't be declared inside other functions.

The line that reads func _on_Dash_timeout() should not be indented at all. I also suspect it belongs at the end, not in the middle of your movement code.

by (21,529 points)
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 Frequently asked questions and 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 [email protected] with your username.