the spawn timer should spawn an item once and then only again when the player has picked up the item

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By marty2022

Hi. I have a SpawnTimer, that spawn an Item, then after time lapse another Item, and another and another… So i want, that the Timer first work again, after the Player has collected the Item. Can anybody help me?
Here are my Script:

extends Node

onready var spawnTimer := $SpawnTimer
var nextSpawnTime := 5

var location = Vector3()
var pack_scene = [
preload (“res://Pickup_Ammo.tscn”)

func _ready():

func _on_Timer_timeout():
var x = randi () % pack_scene.size()

location.x = rand_range (50, 50)
location.z = rand_range (-30, -30)
location.y = rand_range (2, 2)

var scene = pack_scene[x].instance()
add_child (scene)

When the timer fires, check if the item has been collected. If not, don’t create another one.

SteveSmith | 2022-10-02 17:58