|
@@ -3,6 +3,7 @@ extends Node3D
|
|
|
|
|
|
|
|
|
const COLLECT_ANIM := "collection"
|
|
|
+const COLLECT_DURATION := 2.0
|
|
|
|
|
|
@onready var chocolateAnimation: AnimationPlayer = $ChocolateAnimation
|
|
|
@onready var pickupSound: AudioStreamPlayer3D = $ChocolatePickupSound
|
|
@@ -21,12 +22,18 @@ func _on_chocolate_tablet_body_entered(body: Node3D) -> void:
|
|
|
|
|
|
func _give_chocolate_to(walker: Walker) -> void:
|
|
|
walker.give_chocolate()
|
|
|
- reparent.call_deferred(walker)
|
|
|
+ _go_to.call_deferred(walker)
|
|
|
chocolateAnimation.play(COLLECT_ANIM)
|
|
|
chocolateAnimation.animation_finished.connect(_finish)
|
|
|
pickupSound.play()
|
|
|
|
|
|
|
|
|
+func _go_to(walker: Walker) -> void:
|
|
|
+ reparent(walker)
|
|
|
+ var center_tween = create_tween()
|
|
|
+ center_tween.tween_property(self, "position", walker.get_pocket_position(), COLLECT_DURATION)
|
|
|
+
|
|
|
+
|
|
|
func _finish(animation_name: String) -> void:
|
|
|
if COLLECT_ANIM == animation_name:
|
|
|
# Collection is finished
|