The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

I am showing a sprite and would like to have a coded way to make a sprite disappear after showing for five second without using animations.

in Engine by (60 points)

3 Answers

+1 vote
Best answer

Have you looked into using a Timer? Set the Timer to "One shot", then assign its timeout() signal to some script (such as the sprite's script). Set the signal function (the one that's usually called _on_timer_timeout()) to either hide the sprite, or free it completely. The function would look like this:

# In the sprite script.
func _on_timer_timeout():
    # Either call this function or hide()
    queue_free()
by (3,164 points)
selected by
0 votes

You can show the sprite start a timer then use the timer's timeout signal

func on_timer_timeout():
    $Sprite.visible = false
by (96 points)
0 votes

I'm new to Godot but I think you can use the timer node and use signal to connect it to the sprite. Then on the inspector increase wait to 5.
That's it I think

by (14 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 Frequently asked questions and 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 [email protected] with your username.