Add explosion effect to explosive component and implement cleanup functionality

This commit is contained in:
2025-05-01 21:06:26 +02:00
parent ebfd5f0e60
commit 8c9afeee27
6 changed files with 72 additions and 6 deletions

View File

@@ -0,0 +1,8 @@
class_name CleanUpComponent
extends Node
@export var root: Node
func clean_up() -> void:
root.queue_free()

View File

@@ -39,9 +39,10 @@ func explode() -> void:
timer.stop()
if explosion_effect:
var effect: Node2D = explosion_effect.instantiate()
root.get_parent().add_child(effect)
effect.global_position = root.global_position
var explosion_instance: GPUParticles2D = explosion_effect.instantiate()
explosion_instance.global_position = root.global_position
get_tree().current_scene.add_child(explosion_instance)
explosion_instance.emitting = true
var bodies: Array = explosion_area2d.get_overlapping_bodies()
for body in bodies: