17 lines
561 B
GDScript
17 lines
561 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")
|
|
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
|