breakable barrels
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user