break-utopia/project/objects/destructable_props/plant_destroyed.tscn
2026-01-21 17:06:18 +01:00

40 lines
1.7 KiB
Text

[gd_scene format=3 uid="uid://duoim0grg6qqt"]
[ext_resource type="PackedScene" uid="uid://tqmr8aamvolc" path="res://assets/models/props/fragments/token_plant_fragments.blend" id="1_741bf"]
[ext_resource type="PackedScene" uid="uid://tdwettjsx1o2" path="res://objects/effects/impact_flash_green_large.tscn" id="2_qpe3a"]
[ext_resource type="Material" uid="uid://7d4c1oui1np3" path="res://assets/effects/particle_materials/explosion_dithered.tres" id="3_pa6re"]
[sub_resource type="GDScript" id="GDScript_741bf"]
resource_name = "PlantDestroyed"
script/source = "extends Node3D
var count : int = 0
func _ready():
$ImpactFlash2.restart()
await PlayerCamera.get_instance().impact_effect($ImpactFlash2.process_material.color, 0.1, 0.0, 0.02).timeout
iter($token_plant_fragments)
func iter(node):
for child in node.get_children():
if child is RigidBody3D:
child.linear_velocity = ((child.global_position - global_position).normalized() + Vector3(1, 0 ,0).rotated(Vector3.UP, randf_range(0, PI*2)).normalized()) * 4
child.angular_velocity = Vector3(randf_range(4, 5), randf_range(4, 5), randf_range(4, 5))
count += 1
if count % 3 != 0:
get_tree().create_timer(5 + (count % 5)).timeout.connect(child.queue_free)
iter(child)
"
[sub_resource type="QuadMesh" id="QuadMesh_oidwd"]
material = ExtResource("3_pa6re")
center_offset = Vector3(0, 0, -0.1)
[node name="PlantDestroyed" type="Node3D" unique_id=2014770773]
script = SubResource("GDScript_741bf")
[node name="token_plant_fragments" parent="." unique_id=1198837406 instance=ExtResource("1_741bf")]
[node name="ImpactFlash2" parent="." unique_id=297038791 instance=ExtResource("2_qpe3a")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00251311, 0.8627373, 0)
draw_pass_1 = SubResource("QuadMesh_oidwd")