0 votes

I'm totally new about this engine .
I wanted to make a sprite disappear after 1~2 second so I did it like

extends Sprite
var timer
var sprite
funcready():
$Sprite.visible = true
var t = rand
range(1,2)
yield(gettree).createtimer(t),"timeout")
$Sprite.visible = false
and then it got an error (get_node:Node not found :Sprite

How can I solve this problem?

Godot version v3.2.3stable.official
in Engine by (22 points)

1 Answer

0 votes

The error says just what the problem is - there's no node named "Sprite" attached to this one. $Sprite means the same thing as get_node("Sprite"), which translates to "Get a child of this node named 'Sprite'".

It appears you have this script on your Sprite node, so of course there's no child also called "Sprite". If this script is on the sprite that you want to hide, then you don't need to get any node, and you can just say

visible = false
by (20,679 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 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.