44 lines
1.3 KiB
GDScript3
Raw Normal View History

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
var collected_by: Player
func _ready():
particles = %Particles
trails = %Trail
light = %Light
sprite = %Sprite
area = %Area
attractor = %Attractor
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):
if body is Player:
collected_by = body
attractor.visible = false
area.set_deferred("monitoring", false)
particles.process_material.attractor_interaction_enabled = true
2024-02-13 15:45:38 +00:00
2024-02-12 08:53:15 +00:00
var tween = get_tree().create_tween()
2024-02-13 15:45:38 +00:00
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)
2024-02-12 08:53:15 +00:00
await tween.finished
await get_tree().create_timer(2.0).timeout
queue_free()