frame-of-mind/src/base-environments/transition/code/dolly.gd

36 lines
1.1 KiB
GDScript3
Raw Normal View History

2026-01-20 11:37:17 +00:00
## A dolly tweens all contents to and from two destination points, and to its origin.
class_name Dolly
extends Node3D
2026-01-20 11:37:17 +00:00
@export var start_arrived : bool = false
@export var arrival_time : float = 10.0
@export var leave_time : float = 12.0
@onready var origination : Node3D = $Origination
@onready var destination : Node3D = $Destination
var tween : Tween = null
func _ready() -> void:
if not start_arrived:
for child in get_children(true):
if not child.visible: continue
child.global_position = origination.global_position
func arrive() -> void:
if tween: tween.kill()
tween = create_tween().set_trans(Tween.TRANS_CIRC).set_ease(Tween.EASE_OUT)
for child in get_children(true):
if not child.visible: continue
tween.parallel().tween_property(child, "global_position", self.global_position, arrival_time)
func leave() -> void:
if tween: tween.kill()
tween = create_tween().set_trans(Tween.TRANS_QUART).set_ease(Tween.EASE_IN)
for child in get_children(true):
if not child.visible: continue
tween.parallel().tween_property(child, "global_position", destination.global_position, leave_time)