added chest and chest spawners but they don't always show up?
This commit is contained in:
34
scripts/chest_1.gd
Normal file
34
scripts/chest_1.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends RigidBody3D
|
||||
|
||||
@export var weapon_drops : Array[Resource]
|
||||
|
||||
var open = false
|
||||
var drop_weapon
|
||||
|
||||
@onready var anim_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var item_spawn: RayCast3D = $itemspawn
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
drop_weapon = weapon_drops.pick_random().instantiate()
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func hit(dam):
|
||||
if !open:
|
||||
anim_player.play("open")
|
||||
open = true
|
||||
|
||||
func spawn_drop():
|
||||
drop_weapon.position = item_spawn.global_position
|
||||
drop_weapon.transform.basis = item_spawn.global_transform.basis
|
||||
drop_weapon.scale = Vector3(1,1,1)
|
||||
drop_weapon.linear_velocity += Vector3(0,0,-5.0) * item_spawn.global_transform.basis
|
||||
get_tree().current_scene.add_child(drop_weapon)
|
||||
|
||||
func interact():
|
||||
hit(0)
|
||||
Reference in New Issue
Block a user