Sure ! You can create a timer for that either by code or by adding Timer node in your Bullet scene. I think you should add a Timer node in your Bullet Scene. How ? Select your Bullet Scene and add a Timer node to it just like you add Sprite, CollisionBody2D etc nodes. After that select that Timer Node and go to Inspector Tab on the rightmost part of engine where you can set the Wait Time
to 5 and One Shot
to true. After this just go to Node Tab that is on the right side of Inspector tab and under signals connect the timeout
to your bullet script. It will create a function in your bullet script where you simply have to add queue_free()
statement
You can also make a Timer using code like this :
func _ready():
bullet_free_timer = Timer.new()
bullet_free_timer.set_wait_time(5) # 5 seconds wait time
bullet_free_timer.set_one_shot(true)
add_child(bullet_free_timer)
shoot_timer.start()
shoot_timer.connect("timeout", self, "remove_bullet")
func remove_bullet():
queue_free()