Files
Bullosseum/tscn_s/barrel_broken.gd
T
2026-08-28 19:02:19 +03:00

27 lines
860 B
GDScript

extends Node3D
func _ready() -> void:
# 1. Set up the collision layers for the debris pieces
for child in get_children():
if child is RigidBody3D:
child.collision_layer = 2
# 2. Wait 4 seconds while the pieces settle on the ground
await get_tree().create_timer(5.0).timeout
# 3. Create a smooth 1-second fade out before deleting
var tween = create_tween().set_parallel(true)
for child in get_children():
if child is RigidBody3D:
for sub_child in child.get_children():
if sub_child is MeshInstance3D || sub_child.get_class() == "ImporterMeshInstance3D":
# Inside your tween loop:
# Shrinks the physical fragments to nothing over 1 second
tween.tween_property(child, "scale", Vector3.ZERO, 0.3)
# 4. Delete the scene once the fade finishes
await get_tree().create_timer(0.29).timeout
queue_free()