0 votes

It gives me this error. Is there something wrong with my code?

extends KinematicBody2D

const UP = Vector2(0,-1)
var motion = Vector2()
var is_dead = false
var grav = 18
var timer = null
var is_dashing = false

func _physics_process(delta):
    if is_dashing == true:
        motion.y += grav
        motion.x += 1000
    if is_dead == false:
        motion.y += grav

        motion.x = 300
        if Input.is_action_pressed("ui_right"):
            dash()
        if is_on_floor():
            if Input.is_action_just_pressed("ui_select"):
                motion.y = -400
                if Pixel.has_node("pass_through"):
                    Pixel.set_collision_mask_bit(1,false)
                else:
                    motion.y = -400
        move_and_slide(motion,UP)

        if get_slide_count():
            for i in range(get_slide_count()):
                if "Fire" in get_slide_collision(i).collider.name:
                    dead()
        if get_slide_count():
            for i in range(get_slide_count()):
                if "Flame" in get_slide_collision(i).collider.name:
                    dead()


func dead():
    is_dead = true
    $DeathSound.play()
    motion = Vector2(0,0)
    $Particles2D.emitting = true
    $Sprite.play("dead")
    $CollisionShape2D.disabled = true
    $deadtimer.start()

func _on_Luck_Bits_body_entered(body):
    global.luckscore +=1
    print(global.luckscore)

func _on_Spring_body_entered(body):
    motion.y = -500

func _on_deadtimer_timeout():
    get_tree().reload_current_scene()

func _on_dashtimer_timeout():
    motion.x = 300

func dash():
    is_dashing = true
    motion.x = 5000
    $dashtimer.start()
in Engine by (28 points)

If there's still problems, call print_tree_pretty() post the output here. Remember to format it with { } button.

 ┖╴Pixel
 ┖╴Pixel
    ┠╴Sprite
    ┠╴CollisionShape2D
    ┠╴Camera2D
    ┠╴deadtimer
    ┠╴ParallaxBackground
    ┃  ┖╴ParallaxLayer
    ┃     ┖╴Volcano
    ┠╴Particles2D
    ┠╴PauseButton
    ┠╴DeathSound
    ┠╴pass_through
    ┃  ┖╴CollisionShape2D
    ┖╴dashtimer

Why there's two Pixel? Maybe it's the first one that has no timers.

I'm pretty new to this community so I have no idea why there are 2 Pixel? What are the reasons you think for it being here? Also, should I try to find and delete it?
I think the first Pixel might be because I have multiple level scenes in my game so I saved Pixel as its own scene so maybe that's why there might be 2 pixel

1 Answer

0 votes

Either there's no timers named deadtimer or dashtimer in your scene or the names are incorrect.

by (4,103 points)

There are both the timers and the names are correct. Is there any other solution?

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.