0 votes

I set my timer node as set_one_shot(true). And when the timer hits 0, it queue_free() the base node (Rigidbody2D) But now everytime I load the scene godot crashes. It gets even weirder. If the Rigidbody2D scene is loaded in another scene. It deletes it self, in the editor window!

in Engine by (266 points)
edited by

didn't you use tool keyword?

Yes i used the tool keyword. Sorry I didn't include that bit.
Infact I probably should have included the code that came with this whole issue.

tool
extends KinematicBody2D
var delayt = Timer.new()

export var delaydeath = 3 

func _ready():
    #Set up a timer node
    delayt.set_name("delaytimer")
    delayt.set_wait_time(delaydeath)
    delayt.set_one_shot(true)
    delayt.start()
    set_fixed_process(true)
    pass

func _fixed_process(delta):
    if delayt.get_time_left() == 0:
        queue_free()
        pass

1 Answer

0 votes
Best answer

Tools run in the editor, you are running a tool that deletes itself in-editor.

Is ok what you see, the crash may be produced because the loaded scene removes the root inside the editor as you wanted with that code.

by (7,822 points)
selected by
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.

Categories