Attention | Topic was automatically imported from the old Question2Answer platform. | |
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():
randomize()
spawnTimer.start(nextSpawnTime)
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()
scene.set_translation(location)
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