extends GPUParticles3D
var _reparent_timer: Timer

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	# Create and start timer
	_reparent_timer = Timer.new()
	_reparent_timer.wait_time = 1.0
	_reparent_timer.timeout.connect(_try_reparent_to_camera)
	add_child(_reparent_timer)
	_reparent_timer.start()
	
	# Try initial reparent
	_try_reparent_to_camera()

func _try_reparent_to_camera() -> void:
	var camera = get_viewport().get_camera_3d()
	if camera and get_parent() != camera:
		# Reparent to camera
		get_parent().remove_child(self)
		camera.add_child(self)
