class_name ItemSpawner extends Node3D @export var item:ItemResource = null @export var spawn_chance:float = 0.2 @onready var pickup_item_scene:PackedScene = preload("res://objects/pickup_item.tscn") func spawn() -> void: if spawn_chance >= 1.0 or randf() < spawn_chance: var pickup_item:PickupItem = pickup_item_scene.instantiate() pickup_item.item = item pickup_item.world_item_initial_y_position = 0.5 pickup_item.world_item_initial_y_velocity = 3.0 get_parent().add_child(pickup_item) pickup_item.global_transform = global_transform