Problem With Signals 2D Tutorial - Timer Node Not Found
Asked Answered
R

4

0

Hello guyz, I'm just exploring godot and I'm following this:
https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html
I've my sprite2d node with a Timer.

With the sprite sprite2d I've the following script, like the tutorial said:

func _ready():
var timer = get_node("Timer")
timer.timeout.connect(_on_timer_timeout)

The problem is that get_node("Timer") returns null. Probably it's my fault, but can you guess where I'm wrong?

Reputable answered 16/3 at 18:54 Comment(0)
I
0

Are there any error messages?

Add the two debug statements as shown below and post the output:

func _ready():
        print_debug("node '%s' tree follows:" % name) # debug
        print_tree() # debug
        var timer = get_node("Timer")
        timer.timeout.connect(_on_timer_timeout)
Ignore answered 16/3 at 19:58 Comment(0)
R
0

Ignore

Hi, this is the output, No Timer found:

node 'Sprite2D' tree follows:
At: res://sprite_2D.gd:6:_ready()
.

This is the error:
E 0:00:00:0846 sprite_2D.gd:8 @ _ready(): Node not found: "Timer" (relative to "/root/Sprite2D").
<Errore C++> Method/function failed. Returning: nullptr
<Sorgente C++> scene/main/node.cpp:1638 @ get_node()
<Impila Traccia>sprite_2D.gd:8 @ _ready()

This is the Timer Node Tree:
Sprite2D/Timer

rotatingicon.zip
2MB

I've attached the project here

Reputable answered 17/3 at 8:56 Comment(0)
A
1

Reputable I've attached the project here

You have the main scene sprite_2d.tscn change it in the project settings to node_2d.tscn.

Abaca answered 17/3 at 13:1 Comment(0)
R
0

Abaca

Thank you so much, that was so easy 🤯

Reputable answered 17/3 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.