2024-02-12 08:53:15 +00:00
|
|
|
extends Node3D
|
|
|
|
|
2024-02-13 15:45:38 +00:00
|
|
|
@export var tween_duration := 0.5
|
|
|
|
|
2024-02-12 08:53:15 +00:00
|
|
|
var particles: GPUParticles3D
|
|
|
|
var trails: GPUParticles3D
|
|
|
|
var attractor: GPUParticlesAttractor3D
|
|
|
|
var light: Light3D
|
|
|
|
var sprite: Sprite3D
|
|
|
|
var area: Area3D
|
2024-02-16 21:59:23 +00:00
|
|
|
var sound: AudioStreamPlayer3D
|
2024-02-12 08:53:15 +00:00
|
|
|
var collected_by: Player
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
particles = %Particles
|
|
|
|
trails = %Trail
|
|
|
|
light = %Light
|
|
|
|
sprite = %Sprite
|
|
|
|
area = %Area
|
|
|
|
attractor = %Attractor
|
2024-02-16 21:59:23 +00:00
|
|
|
sound = %Sound
|
2024-02-12 08:53:15 +00:00
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
if !collected_by:
|
|
|
|
return
|
|
|
|
|
2024-02-16 11:51:05 +00:00
|
|
|
global_position = Math.damp(global_position, Global.player.global_position + Vector3.UP, 1.0 * delta)
|
2024-02-12 08:53:15 +00:00
|
|
|
|
|
|
|
func on_body_entered(body: Node3D):
|
2024-02-16 21:59:23 +00:00
|
|
|
if not body is Player:
|
|
|
|
return
|
|
|
|
|
|
|
|
collected_by = body
|
|
|
|
attractor.visible = false
|
|
|
|
area.set_deferred("monitoring", false)
|
|
|
|
particles.process_material.attractor_interaction_enabled = true
|
|
|
|
sound.play()
|
|
|
|
|
|
|
|
var tween = get_tree().create_tween()
|
|
|
|
tween.parallel().tween_property(particles, "amount_ratio", 0, tween_duration)
|
|
|
|
# tween.parallel().tween_property(trails, "amount_ratio", 0, tween_duration)
|
|
|
|
tween.parallel().tween_property(light, "light_energy", 0, tween_duration)
|
|
|
|
tween.parallel().tween_property(sprite, "scale", Vector3.ZERO, tween_duration)
|
|
|
|
tween.parallel().tween_property(sprite, "material_override:albedo_color", Color(0, 0, 0, 0), tween_duration)
|
|
|
|
await tween.finished
|
|
|
|
await get_tree().create_timer(2.0).timeout
|
|
|
|
queue_free()
|