44 lines
1.2 KiB
GDScript
44 lines
1.2 KiB
GDScript
extends Node3D
|
|
|
|
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
|
|
|
|
position = lerp(position, Global.player.position + Vector3.UP, 1.0 * delta)
|
|
|
|
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
|
|
var duration := 0.5
|
|
|
|
var tween = get_tree().create_tween()
|
|
tween.parallel().tween_property(particles, "amount_ratio", 0, duration)
|
|
# tween.parallel().tween_property(trails, "amount_ratio", 0, duration)
|
|
tween.parallel().tween_property(light, "light_energy", 0, duration)
|
|
tween.parallel().tween_property(sprite, "scale", Vector3.ZERO, duration)
|
|
tween.parallel().tween_property(sprite, "material_override:albedo_color", Color(0, 0, 0, 0), duration)
|
|
await tween.finished
|
|
await get_tree().create_timer(2.0).timeout
|
|
queue_free()
|
|
# tween.tween_callback(queue_free)
|