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!

asked Apr 5, 2017 in Engine by lavaduder (263 points)
edited Apr 5, 2017 by volzhs

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.

answered Apr 5, 2017 by eons (7,759 points)
selected Jun 30, 2017 by lavaduder
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.