15 lines
461 B
GDScript
15 lines
461 B
GDScript
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 randf() < spawn_chance:
|
|
var pickup_item:PickupItem = pickup_item_scene.instantiate()
|
|
pickup_item.item = load("res://data/items/seeds.tres")
|
|
get_parent().add_child(pickup_item)
|
|
pickup_item.global_transform = global_transform
|